Repository navigation
fix: make @types/codemirror a dependency of @graphiql/react - #2716
Conversation
🦋 Changeset detectedLatest commit: cd38f05 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
thomasheyenbrock
left a comment
There was a problem hiding this comment.
Hey @SimenB and thanks for opening this PR 🙏
I ran into this myself before and had the same thought. My concern here is that this would enforce a TypeScript-specific dependency to all users of this package, no matter if they use TS of JS. Instead I would prefer to guide users to install @types/codemirror themselves if they use TS (basically what the error message you posted says). This is something that we should definitely call out in the README.
I'm requesting changes because of this concern for now. I'd be very interested to see how other libraries solve that problem before moving forward with this approach.
If this is done, it should be set as an optional peer dependency. Otherwise users of yarn2/3 in PnP mode will encounter errors due to the undeclared dependency. |
|
Thanks for the suggestion @andreialecu! Making it an optional peer dependency sounds like the best solution for me. |
|
Yeah, same with pnpm, otherwise you rely on implementation details of hoisting. If you go with peer dep, make sure to add it to all modules that depend on I personally prefer adding the dependency just to not force users who don't care one bit about what your type dependencies are to add it. It would also fall apart if But yeah, a peer dep is way better than no dep at least 🙂 |
+1 for this |
|
On top of all the good reasons for this given by @SimenB , it's also of course completely harmless to add it to Counterpoint: npm@7 (and matching pnpm releases) automatically installs peer dependencies by default again Nice to think about: When we move to monaco editor and eventually codemirror 6, we won't need to import a |
dimaMachina
left a comment
There was a problem hiding this comment.
I am fine to include this in v3, as @acao said, anyway, we'll take away this @types dependency in v4 with monaco-editor integration
Without this, I get type errors in my project