I have run into a situation where a type definition in node_modules/@types
is installing its own @types dependencies, and these "nested" @types conflict with my top level @types.
@types
|-angular //v1.5
|-angular-ui-bootstrap
|-node_modules
|-@types
|-angular //v1.6
How can I exclude node_modules/@types/**/node_modules
in my tsconfig?
One caveat - I am using awesome-typescript-loader, which may have some limitations.
What I've tried:
1 - file glob in the exclude
property to exclude the nested node_modules
compilerOptions.exclude: '../node_modules/@types/**/node_modules'
2 - declaring types
explicitly
compilerOptions.types: ['angular', 'angular-ui-bootstrap']
3 - file glob in the typeRoots
to exclude nested node_modules
compilerOptions.typeRoots: ['../node_modules/@types/**/!(node_modules)']
What I've learned
1 - exclude doesn't seem to work with @types
2 - including a type with "types" means including its dependent @types
3 - typeRoots doesn't seem to work with file globs (or I'm writing the glob wrong)
Related:
Exclude @types typings in installed dependencies
https://github.com/Microsoft/TypeScript/issues/9731
https://github.com/Microsoft/TypeScript/issues/11917
https://github.com/s-panferov/awesome-typescript-loader/issues/492
tsconfig - How to ignore @types/whatever/node_modules for a specific directory?
Details on my environment
"node": "8.6.0", "typescript: "2.8.3", "awesome-typescript-loader": "5.0.0", "webpack": "4.8.3",
ngController
in some parts. I'm hoping for a solution that I can implement now, without coordinating with teammates and doing extensive regression testing. β Squirrelangular-ui-bootstrap
is always going to want the later version of the types. β Absher