Serge Nikitin
Serge Nikitin

Reputation: 1798

How to exclude *.d.ts file for TypeScript compiler?

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

Upvotes: 28

Views: 21027

Answers (1)

t7yang
t7yang

Reputation: 754

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

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

Upvotes: 42

Related Questions