Skip to content

fix(65695): rewrite references in commonjs catch bindings - #65702

Merged
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
a-tarasyuk:fix/65695
Nov 26, 2026
Merged

Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
a-tarasyuk:fix/65695

Conversation

@a-tarasyuk

Copy link
Copy Markdown
Contributor

Fixes #65695

Copilot AI balanced review requested due to automatic review settings November 26, 2026 19:17
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 26, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 26, 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 were identified for the CommonJS catch-binding fix.

No open issues 🎉

What changed in this PR

Fixes #65695 by making the CommonJS transformer visit top-level catch bindings, so imported and exported references are rewritten correctly instead of causing runtime ReferenceErrors.

Changes:

  • Visits catch variable declarations while preserving the existing catch-body traversal.
  • Adds regression tests and an emit baseline covering defaults, computed keys, nested patterns, shadowing, optional bindings, and exported variables.
File Description
tsc/​testdata/​tests/​cases/​compiler/​commonjsCatchBinding.ts Adds CommonJS catch-binding regression cases.
tsc/​testdata/​baselines/​reference/​compiler/​commonjsCatchBinding.js Records expected reference rewriting and preserved binding behavior.
tsc/​internal/​transformers/​moduletransforms/​commonjsmodule.go Visits variable declarations in top-level nested catch clauses.

Review effort: Balanced

@jakebailey Jake Bailey (jakebailey) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 26, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Nov 26, 2026
Merged via the queue into microsoft:main with commit c696807 Nov 26, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Regression from 6.0: CommonJS emit leaves imported and exported names unrewritten in the binding of a top-level catch clause (ReferenceError)

3 participants