Can't import `@graphql-codegen/typescript-react-apollo/typings/config` under `moduleresolution: node16`

33 views Asked by At

In my GraphQL codegen config I use

import type { ReactApolloRawPluginConfig } from '@graphql-codegen/typescript-react-apollo/typings/config';

This worked fine, but now another package requires

    "module": "node16",
    "moduleResolution": "node16",

(or nodenext) in tsconfig.json, and I get this error:

codegen.ts:4:49 - error TS2307: Cannot find module '@graphql-codegen/typescript-react-apollo/typings/config' or its corresponding type declarations.

4 import type { ReactApolloRawPluginConfig } from '@graphql-codegen/typescript-react-apollo/typings/config';
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Is there a proper way to import the type? I could simply write the options object without the type, but want the type-safety.

Here is the package structure:

node_modules/@graphql-codegen/typescript-react-apollo/
|-- cjs
|   |-- config.js
|   |-- index.js
|   |-- package.json
|   `-- visitor.js
|-- esm
|   |-- config.js
|   |-- index.js
|   `-- visitor.js
|-- node_modules
|   |...
|-- package.json
`-- typings
    |-- config.d.cts
    |-- config.d.ts
    |-- index.d.cts
    |-- index.d.ts
    |-- visitor.d.cts
    `-- visitor.d.ts

You can see https://github.com/alexeyr-ci/graphql-code-generator-issue-sandbox/tree/typescript-react-apollo-config-import for a reproduction.

0

There are 0 answers