-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Compilation should not remove uninitialized properties from a class #3232
Comments
m |
I've filed an issue on Next.js the other day about this problem (vercel/next.js#32356), I'm pretty sure it affects many other projects as well. Looking forward to this fix. |
I checked this using babel repl and babel emits nothing for uninitialized properties. |
tsc doesn't emit it, swc and babel follow its behavior. |
Babel do emit uninitialized properties. |
+1 & mark |
+1 |
Babel won't emit uninitialized field when typescript plugin is enabled. This issue should be closed. |
@Austaras Thank you! |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
Compilation should not remove uninitialized properties from a class.
It is useful to have properties in the class that are not assigned initial values. For example, mobx will listen based on the value of the attribute in the class, and if the attribute that is not assigned an initial value is removed, mobx will not be able to listen to the corresponding attribute. Besides, many people are used to declaring class properties without giving them initial values, and swc compilation can create bugs that developers don't expect.
input.js
output.js (The unInitValue was removed after compilation, expecting it to be there)
Input code
Config
Playground link
https://github.com/flyyuan/swcUsingDemo
Expected behavior
Expect to compile to include attributes in the class that are not given initial values
Actual behavior
Remove attributes in the class that are not given initial values after compilation
Version
1.2.128
Additional context
No response
The text was updated successfully, but these errors were encountered: