Skip to content

fix(@angular/build): prevent syntax corruption in oxc transform [22.1.x] - #33792

Merged
alan-agius4 merged 3 commits into
angular:22.1.xfrom
alan-agius4:cherrypick-oxc-fixes-22.1.x
Aug 6, 2026
Merged

fix(@angular/build): prevent syntax corruption in oxc transform [22.1.x]#33792
alan-agius4 merged 3 commits into
angular:22.1.xfrom
alan-agius4:cherrypick-oxc-fixes-22.1.x

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Cherry-pick of oxc transform syntax corruption fixes for 22.1.x:

  1. Preserve parentheses when unwrapping enum IIFE argument assignments (cherry picked from commit 1e9f7c0e39d295a2757802abdb918e07b46ce244, excluding linker changes).
  2. Use unwrapParentheses for oxc AST assignment check (cherry picked from commit 3a79292b2d75f924b3f9d91ad9a26287c3f206d5).
  3. Prevent syntax corruption for Crockford-style enum IIFEs (cherry picked from commit e7124ef86ae9443cfa15fbb122be586b51eb1b0a).

Fixes #33785

Preserve parentheses when unwrapping enum IIFE argument assignments so expressions like Area || (exports.Area = {}) maintain correct operator precedence.

(cherry picked from commit 1e9f7c0)
…um IIFE

When transforming Crockford-style TypeScript enum IIFEs, ensure all leading and trailing parentheses of the expression statement are removed when moving the IIFE call expression to the var initializer.

Fixes angular#33785

(cherry picked from commit e7124ef86ae9443cfa15fbb122be586b51eb1b0a)
@alan-agius4 alan-agius4 self-assigned this Aug 6, 2026
@alan-agius4
alan-agius4 requested a review from clydin August 6, 2026 07:54
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Aug 6, 2026
@alan-agius4 alan-agius4 linked an issue Aug 6, 2026 that may be closed by this pull request
1 task
@alan-agius4 alan-agius4 removed their assignment Aug 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the oxc-transform Babel plugin to correctly handle and clean up TypeScript enums wrapped in parentheses or containing chained export assignments, preventing dangling parentheses. It also adds comprehensive test cases to verify these scenarios. The feedback suggests checking if the right-hand side argument is already parenthesized before wrapping it in parentheses to avoid redundant double parentheses.

Comment thread packages/angular/build/src/tools/babel/plugins/oxc-transform.ts
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 6, 2026
@alan-agius4
alan-agius4 merged commit c805e5c into angular:22.1.x Aug 6, 2026
64 of 66 checks passed
@alan-agius4
alan-agius4 deleted the cherrypick-oxc-fixes-22.1.x branch August 6, 2026 14:45
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng build ts error unexpected const

2 participants