Reputation: 67
My problem stems from the following scenario:
I am working on package A in Typescript. I have written package B in Typescript as well, which will be added as a dependency in package A.
Package B makes use of two javascript modules (C & D) and directly imports the types from their respective @types libraries (@types/C and @types/D).
While package B can build because it has the @types in the dev dependencies, package A will not as it will complain it has no definition of C and D in its own dependencies.
Is there any way to have it so that A will build, but with the following constraints:
noImplicitAny
has to be set to true in ts-configWhat Im hoping for is a way to either declare new types in B that are basically copies of the types in C and D, or have A somehow not care about the the compilation issues in its node modules.
Upvotes: 0
Views: 64
Reputation: 669
If package B is truly an independent package, then you should only include the compiled .js
files and .d.ts
files from B in A (see the --declaration
flag in TypeScript's compiler options if you aren't currently generating .d.ts
files). This should avoid TypeScript trying to find typings for C and D.
However, if the interface you're exposing from B includes types from C and D, then things get a little more tricky. You can either:
Upvotes: 1