Why is typeRoots not recommended for specifying the location of d.ts files?
Asked Answered
V

0

10

In the following SO comment, which has 19 upvotes, the user says the following with regards to Typescript declaration files and the use of typeRoots:

@Tom It looks for .d.ts files in the same places that it will look for normal .ts files: as specified "files", "include", and "exclude" in the tsconfig.json. I would not recommend using typeRoots for this purpose: that's intended for the location of external type modules (i.e. node_modules/@types), not individual .d.ts files.

Essentially the user is saying that typeRoots should not be used for individual .d.ts files but I'm unsure as to why this is the case. Is there a good reason for this?

To add to my confusion, the ts-node module specifically recommends users to use the typeRoots property in tsconfig.json to declare global type definitions. The documentation outlining this can be found here.

So the question is, should I use typeRoots in the manner outlined by the ts-node documentation to declare global type definitions?

Veroniqueverras answered 23/12, 2020 at 4:54 Comment(1)
Damn no answer ?Lehmann

© 2022 - 2024 — McMap. All rights reserved.