Skip to content

Convert nested rest bindings to assignment targets - #65493

Open
Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/rest-binding-targets
Open

Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/rest-binding-targets

Conversation

@jakebailey

Copy link
Copy Markdown
Member

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.

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.
Copilot AI balanced review requested due to automatic review settings November 14, 2026 00:17
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 14, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 14, 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 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

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