-
Notifications
You must be signed in to change notification settings - Fork 143
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
Unnecessary reassignment of exported class when also used in static class property #710
Comments
I'm also curious why Maybe you could add an option to emit code like Babel does in this case? |
Hey @aleclarson, thanks for reporting! Looks like this specific bug is an issue with shadow/declaration detection and the implementation of live bindings in the imports transform. Normally if you have code like this: export class Foo {}
Foo = "some string"; the second assignment actually updates both the variable and export class Foo {} exports.Foo = Foo;
Foo = exports.Foo = "some string"; But in this case, Sucrase is incorrectly classifying the One workaround is to disable the imports transform and target ESM, though I imagine that probably isn't a reasonable option.
This is due to Sucrase's behavior of transpiling class fields (including static fields) by default. You can actually disable this by passing in the option Unfortunately, class A {
static B = exports.B = B
} exports.A = A; So it's really a bug in identifier parsing and the imports transform, not related to the |
https://sucrase.io/#code=%0Aexport%20class%20B%20%7B%7D%0A%0Aexport%20class%20A%20%7B%0A%20%20static%20B%20%3D%20B%0A%7D
This is the line I'm referring to:
The text was updated successfully, but these errors were encountered: