First you have to understand that I\'m switching from IntelliJ to VSCode (Maybe I was too comfortable the way IntelliJ was looking for modules).
I\'ll mostly use VSCode
The only solution I've found so far is adding the path to Angular packages into typeRoots
of tsconfig.json
. Here's an example:
"typeRoots": ["node_modules/@types", "node_modules/@angular"]
That way, apart from node_modules/@types
, TypeScript looks into the node_modules/@angular
folder and its subfolders for type definitions.
According to the TypeScript docs:
If
typeRoots
is specified, only packages undertypeRoots
will be included.
I don't actually know why nothing was mentioned on that matter in the Angular documentation, which is correct but sounds a bit incomplete in terms of typing discovery:
Many libraries include definition files in their npm packages where both the TypeScript compiler and editors can find them. Angular is one such library. The node_modules/@angular/core/ folder of any Angular application contains several d.ts files that describe parts of Angular.
You don't need to do anything to get typings files for library packages that include d.ts files. Angular packages include them already.