-
-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsc error: Cannot find module 'graphql' or its corresponding type declarations #1371
Comments
Hey, @takanokana. Thanks for reporting this. This issue is tied to the recent discussion around We're looking for contributors to fix this. Would you like to help us out? |
As a first step, I wonder if a patch release removing the optional peerDependency Meta might be a stopgap (npm should, i believe, install peers automatically - but not 100% sure offhand). From there, most users shouldn't be warned / see errors. After that - Separating out the graphql entry might be possible, but not super clear yet |
I'm getting this using the latest version ("msw": "^0.45.0") and I can not compile. I just want to mock my regular API.
any workaround? |
|
this makes the graphql peer dependency required. While the hope is to eventually avoid the need to require the graphql library for users who don't declare graphql requests directly, the current architecture means that many tools fails to properly compile without error/warning without this. Since NPM 7, npm will automatically install peer dependencies, which should avoid consumers of msw having to manually install graphql. re mswjs#1371
removes the previous attempt at making graphql optional by lazily requiring it instead of importing it. This didn't have the intended affect of helping to avoid parsing in many environments, and might be confusing and/or cause friction with a future migration to using native modules and providing an export that can be treeshaken in all environments. re mswjs#1371
We're opening a fix in #1381. Everyone is welcome to participate in the discussion there. |
* fix(package.json): make graphql non-optional peerDependency this makes the graphql peer dependency required. While the hope is to eventually avoid the need to require the graphql library for users who don't declare graphql requests directly, the current architecture means that many tools fails to properly compile without error/warning without this. Since NPM 7, npm will automatically install peer dependencies, which should avoid consumers of msw having to manually install graphql. re #1371 * refactor: graphql imported by import instead of require removes the previous attempt at making graphql optional by lazily requiring it instead of importing it. This didn't have the intended affect of helping to avoid parsing in many environments, and might be confusing and/or cause friction with a future migration to using native modules and providing an export that can be treeshaken in all environments. re #1371 * fix: use type import for graphql types * fix: make graphql a dependency instead of peer
Released: v0.46.1 🎉This has been released in v0.46.1! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
Prerequisites
Environment check
msw
versionNode.js version
v16.11.0
Reproduction repository
https://github.com/takanokana/msw-for-issue
Reproduction steps
1.npm ci
2. npm run typecheck
Current behavior
node_modules/msw/lib/index.d.ts:4:63 - error TS2307: Cannot find module 'graphql' or its corresponding type declarations.
4 import { GraphQLError, OperationTypeNode, DocumentNode } from 'graphql';
Expected behavior
No errors when executing tsc.
The text was updated successfully, but these errors were encountered: