Repository navigation
Bind every destructured parameter in node-builder scopes - #65467
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
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.
Contributor
There was a problem hiding this comment.
🟢 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
continueso 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
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.
Returning from the binding-pattern loop after its first element leaves later parameter names out of the fake scope. Declaration emit can then drop
globalThisqualifiers and resolvetypeofqueries to the parameters instead of the intended globals.Fix that by continuing instead of returning. Surprisingly no test caught this.