Skip to content Skip to sidebar Skip to footer

Is There A Way To Add Type Definition Globally In Typescript 2+?

I have a bunch of simple .ts files. NOT projects (i.e. standalone .ts scripts). They use some node.js functionality. TypeScript and node type definitions are installed via npm inst

Solution 1:

I found the solution. I had to manually specify the typeRoots with the path leading to there npm installed global packages. Like so: tsc --typeRoots /usr/lib/node_modules/@types (you can get the path for your system via npm root -g).

Still not sure why it looks them up without any special work on Windows and doesn't on Ubuntu. Can't tell if it's a bug and if it is then in which version.

Post a Comment for "Is There A Way To Add Type Definition Globally In Typescript 2+?"