Incremental compilation: should editing tsconfig.json invalidate the .tsbuildinfo cache in watch mode?
0 reputation · 08 Dec 2020, 11:50 UTC
With "incremental": true in tsconfig.json, TypeScript writes a .tsbuildinfo file that records the module graph and emit state. In tsc --watch, this lets the compiler skip re-emitting unchanged files, so retries after a failed or partial run do not produce duplicate writes to the output directory.
The behavior I want to pin down is the compatibility boundary around configuration changes. My understanding is that editing tsconfig.json itself — for example adding a compiler option — does not invalidate the incremental cache while a watcher is running, and a rebuild only happens after restarting the watcher or deleting the .tsbuildinfo file. With tsc --build and project references, config changes appear to be handled differently.
There are also related edge cases: noEmitOnError can suppress output in a way that looks like a missing write, and outFile bundling rewrites the entire bundle on any change, losing the fine-grained skip behavior.
Is the lack of automatic cache invalidation on tsconfig.json edits an intentional design decision or a known gap? Is there a documented way to force invalidation without deleting .tsbuildinfo manually? Does the answer differ between plain --watch and --build --watch?