Repository navigation
Convert nested rest bindings to assignment targets - #65493
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
Malformed object rest bindings can still reach CommonJS export emit after the parser reports a syntax error. Leaving their binding patterns in expression positions makes the printer panic instead of completing emit with that diagnostic.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the targeted fix for malformed nested object-rest bindings during CommonJS export emission.
No open issues 🎉
What changed in this PR
Prevents a printer panic in the native TypeScript compiler when malformed nested object rest bindings reach CommonJS export emit, while preserving the syntax diagnostic.
Changes:
- Converts object rest binding names into assignment targets before creating spread assignments.
- Adds a regression test for ES2018 and ESNext.
- Records expected JavaScript, diagnostics, types, and symbols for both targets.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/commonjsExportNestedRestBinding.ts |
Adds the malformed nested rest regression case. |
tsc/testdata/baselines/reference/compiler/commonjsExportNestedRestBinding(target=esnext).types |
Records ESNext type information. |
tsc/testdata/baselines/reference/compiler/commonjsExportNestedRestBinding(target=esnext).symbols |
Records ESNext symbol information. |
tsc/testdata/baselines/reference/compiler/commonjsExportNestedRestBinding(target=esnext).js |
Records ESNext emit without a printer panic. |
tsc/testdata/baselines/reference/compiler/commonjsExportNestedRestBinding(target=esnext).errors.txt |
Preserves the ESNext syntax diagnostic. |
tsc/testdata/baselines/reference/compiler/commonjsExportNestedRestBinding(target=es2018).types |
Records ES2018 type information. |
tsc/testdata/baselines/reference/compiler/commonjsExportNestedRestBinding(target=es2018).symbols |
Records ES2018 symbol information. |
tsc/testdata/baselines/reference/compiler/commonjsExportNestedRestBinding(target=es2018).js |
Records ES2018 emit without a printer panic. |
tsc/testdata/baselines/reference/compiler/commonjsExportNestedRestBinding(target=es2018).errors.txt |
Preserves the ES2018 syntax diagnostic. |
tsc/internal/transformers/utilities.go |
Converts nested rest binding patterns into assignment targets. |
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.
Malformed object rest bindings can still reach CommonJS export emit after the parser reports a syntax error. Leaving their binding patterns in expression positions makes the printer panic instead of completing emit with that diagnostic.
Caught in an audit.