TypeScript Compiler Options
include — TypeScript project configuration
Selects root files through glob patterns relative to the configuration directory. Supported extensions depend on options such as allowJs. Imported dependencies can still enter the program outside the selected root set. Baseline: TypeScript 5.8.3. Default: **/* when files is absent; otherwise empty. 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 src/index.ts and the project checks successfully.
Formal Syntax & Structure
typescript syntaxtypescript
{ "include": [ "src/**/*.ts" ]}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| include | string[] | Top-level TSConfig property; default: **/* when files is absent; otherwise empty. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmit": true }, "include": [ "src/**/*.ts" ]}// File: src/index.ts (omit this label)export const n = 1;// File: test/bad.ts (omit this label)const bad: number = "x";
// Run these commands in order in an isolated project:// tsc -p . --showConfig// tsc -p . --pretty false