jsconfig.json key

exclude

  • Default ["node_modules", "bower_components", "jspm_packages"]
  • Tested with TypeScript 5.9

exclude filters the files that include matched. Its patterns work the same way, relative to the config file, and by default it leaves out node_modules and two older package folders.

What it does not do surprises most people: it does not keep a file out of the program. If an included file imports an excluded one, the excluded file is read, and with checkJs on, checked and reported, as the example shows. To stop checking a file that is still imported, put // @ts-nocheck at its top.

At a glance

Write Folders inside an include pattern that the checker should not start from, such as ["src/vendor"]. It does not stop imports
On the command line No flag: only a config file can set it
Type string[]
Default in TypeScript 5.9 ["node_modules", "bower_components", "jspm_packages"] (plus outDir when one is set)
Description in the tsconfig.json schema Specifies a list of files to be excluded from compilation.

The description is quoted from the tsconfig.json schema published by SchemaStore (Apache-2.0), which carries the descriptions TypeScript does not ship for top-level keys; see the notices.

Examples

src/legacy/pad.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: src/legacy/pad.js(2,21): error TS7006: Parameter 'text' implicitly has an 'any' type. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. src/legacy/pad.js(2,21): error TS7006: Parameter 'text' implicitly has an 'any' type. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. src/legacy/pad.js(2,21): error TS7006: Parameter 'text' implicitly has an 'any' type. checked 21 October 2026
export function pad(text) {error TS7006: Parameter 'text' implicitly has an 'any' type.
  return text.padStart(3, "0");
}
exclude does not stop an imported file from being checked.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": [
    "src/**/*.js"
  ],
  "exclude": [
    "src/legacy"
  ]
}

When exclude helps

For files nothing imports: build output, vendored copies of libraries, fixtures, a scratch folder. Those are the files that only reach the program through include, so exclude really keeps them out.

Gotchas

  • Setting exclude replaces the default list, but there is no need to add node_modules back: in TypeScript 5.9 a ** pattern in include never walks into node_modules anyway.

Sources

Last reviewed 20 October 2026.