How to skip typescript noImplicitAny = true rule in node module packages?

I am creating an angular 2 application using Typescript 2 and Webpack 2. I use awesome-typescript -loader as the loader. I set noImplicitAny = true in tsconfig.json. But some of the npm packages I used implicitly are of type "any". (e.g. angular2 -platform-node). Therefore, I want to skip this rule only for npm packages, but not for my application source. How can I configure for this?

+5
source share
2 answers

You can skip type checking for all declaration files with the skipLibCheck compiler option (added in typescript 2.0)

 { "compilerOptions": { "noImplicitAny": true, "skipLibCheck": true, ... } 
+3
source

You can exclude node_modules , but I set my to false and exclude node_modules . I'm not sure why you need it to set to true.

I use

 awesome-typescript-loader 

This is how I configure my tsconfig.json file.

 { "compilerOptions": { "module": "commonjs", "target": "es6", "noImplicitAny": false, "sourceMap": false, "emitDecoratorMetadata": true, "experimentalDecorators": true }, "exclude": [ "node_modules", "public/js" ] } 
0
source

Source: https://habr.com/ru/post/1260421/


All Articles