TypeScript Reference ยท The tsc Command Line
tsc --listFiles
Reference for tsc --listFiles, --listFilesOnly and --explainFiles: print every file the compiler loads, and find out why a file or library is part of the build.
tsc --listFiles prints the path of every file that is part of the compilation: your sources, the standard library declaration files (lib.*.d.ts), and any .d.ts files pulled in from node_modules. The list is printed after the normal compile.
It helps when a build is slower than expected, when a global type appears from nowhere, or when a file you wrote seems to be ignored.
tsc --listFiles tsc --listFilesOnly tsc --explainFiles
Try it
Which standard library files get loaded depends on target and lib. This example uses APIs from several library files at once, so a program using them would list those declaration files.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Syntax
tsc --listFiles tsc --listFilesOnly tsc --explainFiles
| Flag | Description |
|---|---|
--listFiles |
Compile as usual, then print every file in the program. |
--listFilesOnly |
Print the files and stop: no type checking, no emit. |
--explainFiles |
Print each file with the reason it was included (matched by include, imported by a file, referenced by a /// <reference> directive, or a library file). |
--listEmittedFiles |
Print the output files that were written. |
Edge cases: paths are absolute or relative depending on version and settings; do not parse them with exact string matches. --explainFiles output can be long, so pipe it to a file or grep.
Usage notes
- Why is this global here?
--explainFilestells you which@typespackage or import brought it in. Settingtypesin the tsconfig limits automatic@types/*inclusion. - Slow builds: a huge list often means
includeis too broad or a dependency ships heavy declaration files; also see extendedDiagnostics. - Missing file: if your file is not listed, no
includepattern matches it, or it sits in an excluded folder. - Same as the setting:
listFilesis also a tsconfig option; see listFiles. - Use
--listFilesOnlyfor scripts that need the list quickly, for example to feed a linter.