Fix watch diagnostics when global declaration is removed - #4848
Merged
John Favret (johnfav03) merged 2 commits intoAug 10, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes stale watch diagnostics when a changed script stops contributing to the global scope.
Changes:
- Detects loss of global-scope impact and marks all relevant files changed.
- Adds watch-mode regression coverage for removing and restoring a global declaration.
- Adds the expected watch baseline.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
internal/execute/incremental/programtosnapshot.go |
Invalidates files after global-scope loss. |
internal/execute/tsctests/tscwatch_test.go |
Adds the watch regression scenario. |
testdata/baselines/reference/tscWatch/commandLineWatch/watch-detects-error-across-global-script-files-when-global-decl-removed.js |
Records expected diagnostics and rebuilds. |
Member
|
If it's not too much to ask, do you mind splitting this PR into two commits, where you add the test and baseline into the first commit, then the second commit is the fix with the baseline update that shows that it worked? Hard to tell for sure just from a one commit. |
John Favret (johnfav03)
force-pushed
the
fix-issue-4838
branch
from
August 10, 2026 17:17
13dfcc6 to
8b51468
Compare
Contributor
Author
|
Just split the test and the fix into two commits; with just the test, a clean build should report |
Jake Bailey (jakebailey)
approved these changes
Aug 10, 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.
Fixes #4838
When a script file stopped affecting the global scope, the incremental affected-files calculation used its new
affectsGlobalScopevalue. If a global declaration was commented out or removed, the file no longer affected global scope, so only that file was rechecked. This meant that other files using that variable would retain stale semantic diagnostics and that watch mode would fail to report an error.