How does 'incremental' compilation (and the '.tsbuildinfo' file it generates) speed up repeated 'tsc' invocations during local development?
Short answer
With 'incremental': true, TypeScript writes a .tsbuildinfo file caching information about the previous compilation; on subsequent runs, it uses this cache to determine which files actually need to be reprocessed based on what changed, rather than re-type-checking the entire…
Advertisement
AModel answer
With 'incremental': true, TypeScript writes a .tsbuildinfo file caching information about the previous compilation; on subsequent runs, it uses this cache to determine which files actually need to be reprocessed based on what changed, rather than re-type-checking the entire project from scratch every single time — dramatically speeding up repeated compiles in watch mode or CI.
// tsconfig.json
{
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "./.cache/tsbuildinfo"
}
}Real-world example
Speeding up a large project's repeated local 'tsc --watch' compilations, or caching build state between CI pipeline runs.
Likely follow-ups
- Should the generated .tsbuildinfo file typically be committed to version control, or added to .gitignore?
Related topics