TypeScript Compiler Options

exclude — TypeScript project configuration

Filters files discovered via include. It is not a security or program boundary: a file named by files or imported from a root can still enter the program. Explicit exclude replaces the default exclusions. Baseline: TypeScript 5.8.3. Default: dependency directories and configured outDir by default. Example: create the labeled files in an isolated project and run the commands in order. See companion fixtures for comparison cases and expected results. ShowConfig lists only src/index.ts and the project checks successfully.

Formal Syntax & Structure

typescript syntaxtypescript
{  "exclude": [    "src/hidden.ts"  ]}

Parameters & Attributes

NameTypeDescription
excludestring[]Top-level TSConfig property; default: dependency directories and configured outDir by default.

Working Example

Example Snippettypescript
// File: tsconfig.json (omit this label){  "compilerOptions": {    "target": "ES2022",    "module": "CommonJS",    "strict": true,    "types": [],    "noEmit": true  },  "include": [    "src/**/*.ts"  ],  "exclude": [    "src/hidden.ts"  ]}// File: src/index.ts (omit this label)export const n = 1;// File: src/hidden.ts (omit this label)export const broken: number = "x";
// Run these commands in order in an isolated project:// tsc -p . --showConfig// tsc -p . --pretty false
TypeScript Reference