-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
SWC Decorators not working for var X = @addThing class {}
#8515
Comments
Investigation: In TypeScript, decorators can only be applied to class declarations and not to class expressions. Here is a TypeScript playground where this issue can be verified. You may notice an error in the fourth line stating |
However, in Babel, it works. I will give it a try. |
@magic-akari did your test work? |
**Related issue:** Follow up #8515 - Ts Decorator does not always return a class; we need to give it the correct reference.
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
We are running our code through esbuild first to generate a bundle, and then running it through swc to add the SystemJS layer on top. We have noticed that esbuild converts some classes with decorators from
@addX class C { ... }
tovar C = @addX class { ... }
(because of evanw/esbuild#478)This is all valid JS and works fine. However, SWC seems to fall over when then trying to handle the decorators
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.3.104&code=H4sIAAAAAAAAA32MsQqAIBgG9%2F8pvs2lVwgC16A1R8s%2FElJDJYLw3SvbW266O%2Bv2EDMuaGPG5qVCwRKDg0jBcW8nQUSHjpBo0b1apcK86ZTAZ2ZvEmR4Tp798yIqRNWsVPSZQ145yp%2FoBoq%2FzceMAAAA&config=H4sIAAAAAAAAA22QvW7DMAyE9zxFoDlD26FD1wRBO7RLn4CQz6lS%2FYGkARuB372ykhhxUi2C7qOOR55W63KMpI4tPimLeVsrd9icdRe9i%2FiuVLYpKqIuK45ii3Cqj%2FJU4gOmEgN5eXp%2BNZsr8SkJCmjJC2YVvYIj%2BXf4DJYH%2FgvkrSeRLwpYhis0Ewv4pv80yhCV%2BprABhLLLuucogbu72yK2MAmJk1832JiQ6Tg7EfIia%2FDX%2Bg4J1GmKG3isAzjcSA77K7uj%2BadYIe27HifuM65d%2FDNPykYZHVhXsWWIT%2F3WzuzLqoL08YNdZoCqbNmLhhXt%2FdlDhNS03ncdjE65OohgyjCUc4W07fxD7fu8VM8AgAA
SWC Info output
No response
Expected behavior
I expect the output to contain the following code
Actual behavior
Instead it seems to contain
specifically
as it is applying the decorator to
_class
and not toC
- so the class is exported and usable asC
but it doesnt have the decorators applied to itVersion
1.3.104
Additional context
No response
The text was updated successfully, but these errors were encountered: