Repository navigation
fix(build): build a new program in -b --watch when a referenced config changed - #1036
Merged
camc314 merged 1 commit intoNov 19, 2026
Merged
Conversation
…g changed `tsc -b --watch` reused the previous program of a downstream project for a one-file edit (`reuse_watch_program`, a tsrs-only optimization), even after the `tsconfig.json` of a referenced project changed. `reuse_program` keeps the resolved references and the program diagnostics of the previous program, and it does not run `verify_project_references` again. So after a referenced config became invalid or turned off `composite`, an edit of a downstream file gave the old references: no TS6306, and the program read the old outputs of the referenced project. Go builds a new program in each build (`compileAndEmit` calls `compiler.NewProgram`, `buildtask.go:252`), which runs `verifyProjectReferences` against the current config of each reference (`program.go:1431`). Keep the optimization, and fall back to a full build when any resolved reference of the previous program (also the transitive ones) differs from the config that the host returns now. The host cache keeps the same parsed config across cycles until `reset_config` deletes it or a new file list replaces it, so an edit that leaves every referenced config unchanged still reuses the program. Tests: `watch_b_stale_reference_config` in the tsrs_cli integration tests (the referenced config becomes invalid, or sets `composite: false`, and then a downstream file changes). AI assistance: written with Claude Code.
Contributor
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
camc314
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
-b --watchmode, projectbreferences projecta. Aftera/tsconfig.jsonbecomes invalid or sets"composite": false, an edit ofb/b.tsdid not report TS6306 (Referenced project ... must have setting "composite": true), as tsgo does. tsrs reported TS2322 forb/b.tsinstead.For a one-file edit, the tsrs-only
reuse_watch_programreuses the previous program, so the references are not checked again. Go builds a new program in every build, which runsverifyProjectReferences. tsrs now builds a new program when the host returns a different config for a reference of the previous program, including a transitive one.Tests:
watch_b_stale_reference_config(an invalid config, and"composite": false). Both fail without the fix.AI assistance: written with Claude Code.