Skip to content

Preserve checking globals before declaration signature generation - #64718

Open
Jake Bailey (jakebailey) wants to merge 2 commits into
microsoft:mainfrom
jakebailey:incremental-global-diagnostics
Open

Jake Bailey (jakebailey) wants to merge 2 commits into
microsoft:mainfrom
jakebailey:incremental-global-diagnostics

Conversation

@jakebailey

@jakebailey Jake Bailey (jakebailey) commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

This solves the "expected diff" caused by #64452.

See second commit for the actual change.

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.
Copilot AI balanced review requested due to automatic review settings October 10, 2026 03:18
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants