What is incremental compilation in TypeScript
· Category: TypeScript
Short answer
Incremental compilation saves a summary of the last compilation to a .tsbuildinfo file, allowing TypeScript to skip re-checking unchanged files on subsequent runs.
How it works
When incremental: true is set, TypeScript writes build metadata including file hashes and dependency graphs. On the next invocation, it reads this file to determine what has changed and only re-emits affected outputs. This is especially effective for large codebases.
Example
{
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "./.tsbuildinfo"
}
}
Why it matters
Without incremental builds, every tsc invocation re-checks the entire project. Incremental mode reduces feedback loops during development and CI, especially when combined with project references.