TypeScript Compiler Options
explainFiles — TypeScript compiler diagnostics
Shows program files with reasons for inclusion, such as root selection, imports or library references. Use it when an unexpected file is checked. The exact wording and order are compiler-version-dependent. It does not restrict the program or change emit behavior. Baseline: TypeScript 5.8.3. Default: false. Create the labeled files in an isolated directory and run the commands below. The output identifies the root index.ts and the import that brought dep.ts into the program.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "explainFiles": true }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| explainFiles | boolean | Compiler option; default: false. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES5", "module": "CommonJS", "lib": [ "ES5" ], "strict": true, "types": [], "outDir": "dist", "noEmitOnError": true, "explainFiles": true, "noEmit": true }, "files": [ "index.ts" ]}// File: index.ts (omit this label)import { value } from "./dep";export const count = value;// File: dep.ts (omit this label)export const value = 7;
// Run these commands in order in an isolated project:// tsc -p . --pretty false