Skip to content

Bind every destructured parameter in node-builder scopes - #65467

Merged
Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/destructuring-scope
Nov 16, 2026
Merged

Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/destructuring-scope

Conversation

@jakebailey

Copy link
Copy Markdown
Member

Returning from the binding-pattern loop after its first element leaves later parameter names out of the fake scope. Declaration emit can then drop globalThis qualifiers and resolve typeof queries to the parameters instead of the intended globals.

Fix that by continuing instead of returning. Surprisingly no test caught this.

Returning from the binding-pattern loop after its first element leaves
later parameter names out of the fake scope. Declaration emit can then
drop globalThis qualifiers and resolve typeof queries to the parameters
instead of the intended globals.

Continue through omitted and bound elements, including nested patterns,
so every parameter name shadows the corresponding global during emit.
Cover later array/object entries, omitted slots, and nested siblings in
the existing declaration-emit regression.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 04:42
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 13, 2026
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 13, 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.

🟢 Approval recommended

No active review issues block the destructured-parameter binding fix.

No open issues 🎉

What changed in this PR

This PR fixes declaration emit in the native TypeScript compiler by binding every destructured parameter name in node-builder scopes. This preserves globalThis qualifiers when later parameter bindings shadow global names.

Changes:

  • Replace early returns with continue so all binding-pattern elements are processed.
  • Add regression cases for array, omitted, object, and nested bindings.
  • Update declaration, type, and symbol baselines.
File Description
tsc/​internal/​checker/​nodebuilderscopes.go Continue binding after omitted and bound elements.
tsc/​testdata/​tests/​cases/​compiler/​declarationEmitGlobalThisPreserved.ts Add destructured-parameter regression cases.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitGlobalThisPreserved.js Record declarations retaining globalThis qualifiers.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitGlobalThisPreserved.types Record types for the new cases.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitGlobalThisPreserved.symbols Record new bindings and updated declaration positions.

Review effort: Balanced

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 16, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Nov 16, 2026
Merged via the queue into microsoft:main with commit 3772d1e Nov 16, 2026
34 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the compiler-fixes/destructuring-scope branch November 16, 2026 18:37
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 16, 2026
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: Done

Development

Successfully merging this pull request may close these issues.

3 participants