Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es/decorator): Preserve class prop order #6972

Merged
merged 7 commits into from Feb 23, 2023

Conversation

magic-akari
Copy link
Member

Description:

BREAKING CHANGE:

Related issue (if exists):

@magic-akari
Copy link
Member Author

if (!calledSetterProperty) {
throw new Error("Expected setter to be called!");
}

This test case failed on target: ES2022, since we do not transform class field, the useDefineForClassFields: false does not work.
Any idea?

@kdy1
Copy link
Member

kdy1 commented Feb 22, 2023

Nevermind. You can add .swcrc to force transform

@magic-akari
Copy link
Member Author

magic-akari commented Feb 22, 2023

out.mp4

With target: ES2020, SWC does not transpire class field.
And ECMA native class field always mean [[Define]].

@kdy1
Copy link
Member

kdy1 commented Feb 22, 2023

I think we should lower the jsc.target in this case

@@ -36,6 +36,8 @@ pub(super) fn new(metadata: bool, use_define_for_class_fields: bool) -> TscDecor

pub(super) struct TscDecorator {
metadata: bool,

#[allow(dead_code)]
use_define_for_class_fields: bool,
Copy link
Member Author

Choose a reason for hiding this comment

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

We should leave class fields to be handled in swc_ecma_transforms_compat::es2022::class_properties stage, not decorators.

This use_define_for_class_fields option is not used in this transformation.
Is it safe to remove it wihout breaking changes?

Copy link
Member

Choose a reason for hiding this comment

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

I think so

Copy link
Member

Choose a reason for hiding this comment

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

It's passed, not deserialized from json

@magic-akari magic-akari marked this pull request as ready for review February 22, 2023 11:06
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Thank you!


swc-bump:

  • swc_ecma_transforms_proposal

@kdy1 kdy1 enabled auto-merge (squash) February 22, 2023 13:52
@kdy1 kdy1 added this to the Planned milestone Feb 22, 2023
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

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

Automated review comment generated by auto-rebase script

@kdy1 kdy1 merged commit 703b340 into swc-project:main Feb 23, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.37 Feb 28, 2023
@magic-akari magic-akari deleted the fix/issue-6951 branch March 10, 2023 02:51
@swc-project swc-project locked as resolved and limited conversation to collaborators Apr 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Decorated and regular class properties are translated in a wrong order
3 participants