Graphql-code-generator: [typescript-operations] Missing typings

Created on 7 Dec 2019  路  8Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug

When importing the @graphql-codegen/typescript-operations module with ts-node, I'm getting the following error:

聽error TS7016: Could not find a declaration file for module '@graphql-codegen/typescript-operations'. '/project/node_modules/@graphql-codegen/typescript-operations/index.cjs.js' implicitly has an 'any' type.
  Try `npm install @types/graphql-codegen__typescript-operations` if it exists or add a new declaration (.d.ts) file containing `declare module '@graphql-codegen/typescript-operations';`

21 import * as tsOpPlugin from '@graphql-codegen/typescript-operations';

It looks like the typings.d.ts file referred to in the package.json of the module is not properly generated.

To Reproduce

Example sandbox:
https://codesandbox.io/s/vibrant-brahmagupta-w2pxy?fontsize=14&hidenavigation=1&theme=dark

You can see that the @graphql-codegen/typescript-operations module is not found, contrary to the @graphql-codegen/typescript module which is correctly found.

Environment:

  • @graphql-codegen/typescript-operations: 1.9.1
  • NodeJS: ts-node 8.5.4
bug core waiting-for-release

Most helpful comment

It seems that the types are in a wrong path in 1.11.2.

The package.json points to the package root
https://unpkg.com/browse/@graphql-codegen/typescript[email protected]/package.json

image

But the definitions seem to be in operations/src/

https://unpkg.com/browse/@graphql-codegen/typescript[email protected]/operations/src/

This workaround made it work for me:

cp node_modules/@graphql-codegen/typescript-operations/operations/src/*.d.ts node_modules/@graphql-codegen/typescript-operations

All 8 comments

You are right, @alexkirsz , the typings and typescript keys are missing in package.json while building the bundled artifact.
@kamilkisiela I think this issue is related to bob, can you please take a look?

Fixed by @kamilkisiela and @ardatan in bob :)

Fixed in v1.10.0.

It seems that the types are in a wrong path in 1.11.2.

The package.json points to the package root
https://unpkg.com/browse/@graphql-codegen/typescript[email protected]/package.json

image

But the definitions seem to be in operations/src/

https://unpkg.com/browse/@graphql-codegen/typescript[email protected]/operations/src/

This workaround made it work for me:

cp node_modules/@graphql-codegen/typescript-operations/operations/src/*.d.ts node_modules/@graphql-codegen/typescript-operations

@dotansimha I can confirm this is still an issue on the latest version of @graphql-codegen/typescript-operations (1.11.2)

Found the cause for this. Working on a fix.

Fixed in v1.12.0

Was this page helpful?
0 / 5 - 0 ratings