Use different TypeScript `@types` for sub-dependencies with different versions

Viewed 30

I use package A and B v1 in my application. Package A itself depends on B v2, and it seems like all @types packages use * for their dependency versions. This means that I can only have either B v1 or B v2 in node_modules/@types/B.

What I would expect is to have:

  • v1 in node_modules/@types/B used in my application
  • v2 in node_modules/@types/A/node_modules/B used by A

While writing this question I realised I could do declare module 'A'; declare module 'B'; and just ignore all typings for both packages all together. Is there some other way, keeping the typings for the respective package? Is this not a design flaw in @types packages?

0 Answers
Related