Reputation: 4040
I'm using an untyped (commonJS) external package to build my library. Therefore, I created a .d.ts
file to add those typings. However, these type declarations are not carried over to in my output bundle. How can I assure that they get bundled in my library so that the consumer gets properly typed components?
// untyped package => ./src/types/untypedPackage.d.ts;
declare module "untyped-package" {
// type declarations here
}
I've read that I probably need to use a triple-slash directive on the consumer end, but I also read that it's not a good practice. What's the best way to make this automatic without fiddling with triple-slash directives or copying .d.ts files + to build folder + re-importing them in the consumer project?
Upvotes: 1
Views: 490
Reputation: 2220
Don't put the types in /src
! Many libraries just put it in the root folder. So you won't need to copy it over, but make sure to set typeRoots
in the tsconfig file.
Upvotes: 1