Skip to content

Guard private syntax preservation by transform profile - #58253

Open
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/guard-private-preservation-profile
Open

Guard private syntax preservation by transform profile#58253
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/guard-private-preservation-profile

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary:

customTransformOptions.unstable_preserveClassPrivate currently disables private-field and private-method transforms for every profile. With hermes-legacy, the preset still lowers the surrounding class syntax, and Babel then aborts because its class transform requires the private transforms.

Only preserve private syntax when the selected profile also preserves class syntax. Stable and canary Hermes profiles keep their existing experimental behavior; legacy profiles continue lowering private fields and methods together with classes instead of crashing.

Changelog:

[GENERAL] [FIXED] - Keep private class transforms enabled for profiles that lower classes.

Test Plan:

  • Added a focused hermes-legacy regression containing both a private field and private method with the preservation option enabled.
  • Exact baseline throws Babel's private-method transform error; the fixed preset compiles and emits the normal private-field helpers.
  • Full preset Jest passes: 4/4 suites, 111/111 tests, 16 snapshots.
  • Fresh Flow check reports 0 errors.
  • Targeted no-ignore ESLint, Prettier, and git diff --check pass.

No breaking change: stable/canary preservation is unchanged, while an invalid legacy configuration now compiles correctly.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 30, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant