Skip to content

fix(transformer/typescript): panics when setPublicClassFields = true and the class includes private field#11089

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-17-fix_transformer_typescript_panics_when_setpublicclassfields_true_and_the_class_includes_private_field
May 18, 2025
Merged

fix(transformer/typescript): panics when setPublicClassFields = true and the class includes private field#11089
graphite-app[bot] merged 1 commit intomainfrom
05-17-fix_transformer_typescript_panics_when_setpublicclassfields_true_and_the_class_includes_private_field

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented May 17, 2025

close: #11084

We don't need to transform the private field, which is part of class-properties work, so unreachable is expected. The bug is that we haven't skipped it.

@github-actions github-actions bot added the A-transformer Area - Transformer / Transpiler label May 17, 2025
Copy link
Member Author

Dunqing commented May 17, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the C-bug Category - Bug label May 17, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 17, 2025

CodSpeed Instrumentation Performance Report

Merging #11089 will not alter performance

Comparing 05-17-fix_transformer_typescript_panics_when_setpublicclassfields_true_and_the_class_includes_private_field (d374490) with main (3795eb6)

Summary

✅ 36 untouched benchmarks

@Dunqing Dunqing marked this pull request as ready for review May 17, 2025 14:02
Copilot AI review requested due to automatic review settings May 17, 2025 14:02
@Dunqing Dunqing requested a review from overlookmotel as a code owner May 17, 2025 14:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the TypeScript transformer where the presence of private fields would cause a panic when setPublicClassFields is enabled. The changes ensure that private fields are skipped during transformation and update the relevant tests and snapshots accordingly.

  • Updated tests to include private field syntax in both input and output fixtures.
  • Modified the transformer logic in the TypeScript class file to skip processing private identifiers.
  • Updated snapshots to reflect the new unresolved reference IDs behavior.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tasks/transform_conformance/tests/babel-plugin-transform-typescript/test/fixtures/use-define-for-class-fields-without-class-properties/output.js Added private field syntax to verify transformer behavior for private fields.
tasks/transform_conformance/tests/babel-plugin-transform-typescript/test/fixtures/use-define-for-class-fields-without-class-properties/input.ts Updated input syntax to include private fields for testing.
tasks/transform_conformance/snapshots/oxc.snap.md Adjusted snapshot to match the new unresolved references output.
crates/oxc_transformer/src/typescript/class.rs Modified transformation logic to skip private fields and updated unreachable error message.

@Dunqing Dunqing force-pushed the 05-17-fix_transformer_typescript_panics_when_setpublicclassfields_true_and_the_class_includes_private_field branch from 2dabcd6 to a92ba99 Compare May 17, 2025 14:08
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 18, 2025
Copy link
Member

Boshen commented May 18, 2025

Merge activity

…` and the class includes private field (#11089)

close: #11084

We don't need to transform the private field, which is part of class-properties work, so `unreachable` is expected. The bug is that we haven't skipped it.
@graphite-app graphite-app bot force-pushed the 05-17-fix_transformer_typescript_panics_when_setpublicclassfields_true_and_the_class_includes_private_field branch from a92ba99 to d374490 Compare May 18, 2025 05:10
@graphite-app graphite-app bot merged commit d374490 into main May 18, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 05-17-fix_transformer_typescript_panics_when_setpublicclassfields_true_and_the_class_includes_private_field branch May 18, 2025 05:16
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transformer: panicked when using setPublicClassFields with private properties.

4 participants