Why does tsc ignore include and exclude in tsconfig.json?

Viewed 1041

I have tsconfig.json:

{
  "compilerOptions": {
    "target": "ES6",
    "lib": [
      "DOM",
      "ES6"
    ]
  },
  "include": [
    "src/server/**/*"
  ],
  "exclude": [
    "node_modules",
    "dist",
    "public"
  ]
}

and when I ran tsc --project tsconfig.json it totally ignored the include and exclude configuration and failed on node_modules compilation.

The only way it succeeded was tsc src/server/**/*.ts, but then it did not use the config.

I verified, that the compiler processes the config, because when I added "watch": true to "compilerOptions", it waited for change.

I looked at documentation and I didn't get it. It looked like I placed it on correct position in the json file.

Does anyone have any idea, how to fix it?


Compiler version on macOS Big Sur:

% tsc -v
Version 4.0.5
2 Answers

As written in comment below the issue, I had to add "skipLibCheck": true, so the final json looks like:

{
  "compilerOptions": {
    "target": "ES6",
    "lib": [
      "DOM",
      "ES6"
    ],
    "skipLibCheck": true
  },
  "include": [
    "src/server/**/*"
  ],
  "exclude": [
    "node_modules",
    "dist",
    "public"
  ]
}

Then compilation succeeds:

% tsc -p tsconfig.json 
% echo $?
0

I had the same problem and I solved it but upgrading typescript:

npm install -g typescript 
Related