Typescript – How to exclude *.d.ts file for TypeScript compiler

typescripttypescript-typings

I use a npm module web3@1.0.0-beta.24 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

Best Answer

Try add this options to tsconfig.json to ignore lib declaration files checking while compiling.

{
  "compilerOptions": {
    "skipLibCheck": true
  },
}