Closed yuvalhvim closed 1 year ago
Could you specify this please?
graphql-tag@2.12.6
definitely ships with a lib/index.d.ts
Ok, I should have definitely elaborated a bit more 😅
We have a monorepo and we're using pnpm
.
Some projects in the monorepo are using graphql-tag@2.11.0
, in which index.d.ts
is located right under the root directory of the package under node_modules.
tsc recognizes that index.d.ts
to be the correct one, therefore using its import of graphql
, which results in types mismatch in our effort to upgrade to ApolloServer4.
To bypass this we're using paths
option in tsconfig.json
, but maybe moving index.d.ts
file to be under the root directory could solve this?
Maybe I'm missing the cause of the error entirely? 🤔
TypeScript should look at the types
field in package.json
, which is correct.
Your problem here is that TypeScript generally lacks the concept of "two versions of the same library". If those lib versions had slightly different APIs, TypeScript would only ever check for one of them (potentially hiding bugs from you), or even report errors when loading types (if you have skipLibChecks
turned on).
You need to make sure that you only have one version of a dependency installed.
PS: you might be able to achieve this using pnpm.overrides
Cool, thanks for the answer! I will give it a try :)
I don't see it, and in our monorepo I always get an older version d.ts, which uses an older version of
graphql
, which doesn't allow me to upgrade to ApolloServer4