Skip to main content

consistent-incremental-with-tsbuildinfo

Require tsBuildInfoFile to be explicitly set whenever incremental: true is present in compilerOptions.

Targeted pattern scopeโ€‹

The compilerOptions.incremental and compilerOptions.tsBuildInfoFile fields in any tsconfig*.json file.

What this rule reportsโ€‹

This rule reports when "incremental": true is present in compilerOptions but tsBuildInfoFile is not explicitly configured.

Why this rule existsโ€‹

TypeScript's incremental compilation caches type-checking information in a build-info file. By default the file lands in the compiler's output directory under a generated name. This is fine when there is only one project, but in monorepos or multi-config setups multiple projects will silently overwrite each other's cache, defeating the purpose of incremental builds and causing unexplained cache misses.

Explicitly declaring tsBuildInfoFile makes the path intentional, reviewable, and gitignore-friendly.

โŒ Incorrectโ€‹

{
"compilerOptions": {
"incremental": true
}
}

The tsBuildInfoFile path is unspecified, so TypeScript chooses a default location that may conflict with other projects.

โœ… Correctโ€‹

{
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": ".tsbuildinfo"
}
}

Or disable incremental compilation entirely:

{
"compilerOptions": {
"incremental": false
}
}

When not to use itโ€‹

This rule can be disabled in projects where there is genuinely only one tsconfig.json and the default build-info location is acceptable and committed to .gitignore.

Package documentationโ€‹

Rule catalog ID: R001

Further readingโ€‹