I use a npm module [email protected] which has some mistakes in its index.d.ts file.
I want to ignore this file (node_modules/web3/index.d.ts) for TS compiler and I want to use my own types file.
But tsc still use this wrong file and can't compile my project.
Here is my tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true
},
"exclude": ["node_modules/web3/index.d.ts"]
}
If I manually remove node_modules/web3/index.d.ts
, tsc compiles my project.
How to exclude this file for tsc?
I've created a repo with minimum code to reproduce this problem: https://github.com/serge-nikitin/q1
Use // @ts-ignore to ignore the type checking errors on the next line in a TypeScript file. If you use a linter, you might have to add a comment to also suppress linting errors when using ts-ignore - // eslint-disable-next-line @typescript-eslint/ban-ts-comment .
d. ts is the type definition files that allow to use existing JavaScript code in TypeScript. declare function sum(a: number, b: number): number; From now on, we can use the function in TypeScript without any compile errors.
Use the exclude option in your tsconfig. json file to exclude a folder from compilation in TypeScript. The exclude option changes what the include setting finds and defaults to node_modules and bower_components .
Try add this options to tsconfig.json to ignore lib declaration files checking while compiling.
{
"compilerOptions": {
"skipLibCheck": true
},
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With