TypeScript Compiler Options
excludeDirectories — TypeScript watch configuration
Excludes matching directories from watch registration, not from compiler program inclusion. Paths and patterns are relative to the configuration directory; excluding a directory from watching can cause changes to be missed. The initial check still reports a type error in a source under the excluded directory. The fixture verifies initial inclusion and parsing, not missed-event timing. Baseline: TypeScript 5.8.3. Default: unset. Create the labeled files in an isolated project; omit file labels. Run the indicated command.
Formal Syntax & Structure
typescript syntaxtypescript
{ "watchOptions": { "excludeDirectories": [ "src/generated" ] }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| excludeDirectories | string[] | Watch option; default: unset. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmit": true }, "include": [ "src/**/*.ts" ], "watchOptions": { "excludeDirectories": [ "src/generated" ] }}// File: src/index.ts (omit this label)export const count: number = 1;// File: src/generated/bad.ts (omit this label)export const bad: number = "x";
// Run in a temporary project:// tsc -p . --pretty false