TypeScript Compiler Options
files — TypeScript project configuration
Lists explicit root inputs relative to the configuration. A missing named file is an error; imports may introduce additional files. A solution config can use an empty files list with project references. Baseline: TypeScript 5.8.3. Default: all supported files via default include if neither files nor include is present. 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 index.ts; the unlisted invalid file is not checked.
Formal Syntax & Structure
typescript syntaxtypescript
{ "files": [ "index.ts" ]}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| files | string[] | Top-level TSConfig property; default: all supported files via default include if neither files nor include is present. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmit": true }, "files": [ "index.ts" ]}// File: index.ts (omit this label)export const x = 1;// File: unlisted.ts (omit this label)const bad: number = "x";
// Run these commands in order in an isolated project:// tsc -p . --showConfig// tsc -p . --pretty false