Repository navigation
Preserve checking globals before declaration signature generation - #64718
Open
Jake Bailey (jakebailey) wants to merge 2 commits into
Open
Jake Bailey (jakebailey) wants to merge 2 commits into
Jake Bailey (jakebailey) wants to merge 2 commits into
Conversation
A comment-only change can make build mode stop reporting a missing global type and cache a successful check. Cover this alongside the existing incremental regression before changing diagnostic ordering.
Incremental checking must not lose a missing-global error merely because signature generation discovers it first. Retain each affected file’s checking diagnostics before computing its declaration shape, without collecting incidental emit-only globals or checking emit-only builds.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent semantic checking can overlap non-exclusive declaration emit on the same checker, creating a data race.
1 open finding
What changed in this PR
Preservation of incremental global diagnostics across declaration-signature generation and cached rebuilds
Changes:
- Precompute semantic diagnostics before declaration signatures
- Preserve diagnostic cache and pending-check state
- Add build/watch regression coverage
| File | Description |
|---|---|
tsc/internal/compiler/program.go |
Optimizes single-file diagnostic collection |
tsc/internal/execute/incremental/affectedfileshandler.go |
Preserves diagnostics during signature generation |
tsc/internal/execute/incremental/emitfileshandler.go |
Distinguishes emit-only collection |
tsc/internal/execute/incremental/program.go |
Updates pending-check state |
tsc/internal/execute/tsctests/tsc_test.go |
Adds incremental regression scenarios |
tsc/testdata/baselines/reference/tsc/incremental/global-diagnostics-produced-during-semantic-checking.js |
Updates cached-diagnostic expectations |
tsc/testdata/baselines/reference/tsc/incremental/global-diagnostics-survive-build-signature-generation.js |
Covers build signature generation |
tsc/testdata/baselines/reference/tsc/incremental/global-diagnostics-with-declaration-emit-checkers-1-build-false.js |
Covers one-checker compilation |
tsc/testdata/baselines/reference/tsc/incremental/global-diagnostics-with-declaration-emit-checkers-2-build-false.js |
Covers two-checker compilation |
tsc/testdata/baselines/reference/tscWatch/incremental/global-diagnostics-with-declaration-emit-checkers-1-build-false-watch.js |
Covers one-checker watch mode |
tsc/testdata/baselines/reference/tscWatch/incremental/global-diagnostics-with-declaration-emit-checkers-2-build-false-watch.js |
Covers two-checker watch mode |
tsc/testdata/baselines/reference/tsbuild/incremental/global-diagnostics-with-declaration-emit-checkers-1-build-true.js |
Covers one-checker build mode |
tsc/testdata/baselines/reference/tsbuild/incremental/global-diagnostics-with-declaration-emit-checkers-2-build-true.js |
Covers two-checker build mode |
tsc/testdata/baselines/reference/tsbuildWatch/incremental/global-diagnostics-with-declaration-emit-checkers-1-build-true-watch.js |
Covers one-checker build watch mode |
tsc/testdata/baselines/reference/tsbuildWatch/incremental/global-diagnostics-with-declaration-emit-checkers-2-build-true-watch.js |
Covers two-checker build watch mode |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+106
to
+110
| if h.collectSemanticDiagnostics && !h.program.snapshot.options.NoCheck.IsTrue() { | ||
| // Signature generation can discover globals before checking does. Keep the | ||
| // checking diagnostics first, without retaining incidental emit-only errors. | ||
| update.semanticDiagnostics = &DiagnosticsOrBuildInfoDiagnosticsWithFileName{ | ||
| diagnostics: h.program.program.GetSemanticDiagnosticsForIncremental(h.ctx, core.SingleElementSlice(file))[file], |
This branch has not been deployed
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.

This solves the "expected diff" caused by #64452.
See second commit for the actual change.