TypeScript Reference ยท tsconfig: Projects, Files and Watch Options
TypeScript incremental and tsBuildInfoFile options
Reference for the TypeScript incremental and tsBuildInfoFile options: how the build info file caches work between runs and where it is written.
incremental tells the compiler to save information about the last compilation in a .tsbuildinfo file. On the next run it reads that file, works out which source files changed (and which files depend on them), and only re-checks and re-emits those. For large projects this turns a cold build into a much faster warm one.
tsBuildInfoFile chooses where that cache file is written. Without it, the compiler picks a location from your other settings.
{ "compilerOptions": { "incremental": true, "tsBuildInfoFile": "./.cache/app.tsbuildinfo", "outDir": "dist" } }
Try it
The cache file is written to disk, so these examples simulate the idea: remember a signature per file and recompute only what is affected.
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
{ "compilerOptions": { "incremental": true, "tsBuildInfoFile": "path/to/file.tsbuildinfo" } }
tsc --incremental tsc --incremental --tsBuildInfoFile .cache/app.tsbuildinfo
| Option | Description |
|---|---|
incremental |
Boolean. Defaults to true when composite is on, otherwise false. |
tsBuildInfoFile |
Path of the cache file. Only meaningful together with incremental or composite. |
Default location: beside the output when outDir is set, otherwise next to the tsconfig file, named after it (for example tsconfig.tsbuildinfo). Combined with noEmit the cache can still be written, so type-checking runs also become incremental.
Usage notes
- Do not commit the file. It is a build artifact; add
*.tsbuildinfoto.gitignore. - Cache in CI. Saving the file between runs makes type-check jobs faster, but it must match the checked-out sources and compiler version; a different compiler version simply discards it.
- Delete it when something looks stale. A removed file just means one full build.
- One file per project. Two configs that share a path overwrite each other's cache, so give each its own
tsBuildInfoFile. - Accuracy is unchanged. Incremental builds report the same errors as full builds; only the work is skipped.
tsc --buildmanages the same data for every project in the graph.
Related
- composite
- references
- skipLibCheck
- Tutorial: tsconfig, Large projects