You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we noticed a transpilation error when executing our code via swc-node.
We have a class that returns a different class in one of its methods. The issue we noticed was that some class members were missing at runtime. After some debugging, we noticed that the property assignment is placed inside the wrong constructor (i.e. the one from the other class that is returned in a method). It looks like the properties are always put into the first constructor inside the class declaration - it works correctly if I place the class' own constructor above the method.
The issue only seems to occur when using "useDefineForClassFields": false, which is the default setting in swc-node.
Thanks for looking into it!
Input code
classMyClass{// also same behavior for static methodsmethodReturningClass(){returnclassSomeOtherClass{constructor(){// Assignment to foo goes here}};}constructor(args){// Assignment to foo should go here}foo='bar'}
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
Hi there,
we noticed a transpilation error when executing our code via
swc-node
.We have a class that returns a different class in one of its methods. The issue we noticed was that some class members were missing at runtime. After some debugging, we noticed that the property assignment is placed inside the wrong constructor (i.e. the one from the other class that is returned in a method). It looks like the properties are always put into the first constructor inside the class declaration - it works correctly if I place the class' own constructor above the method.
The issue only seems to occur when using
"useDefineForClassFields": false
, which is the default setting inswc-node
.Thanks for looking into it!
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.4.12&code=H4sIAAAAAAAAA22OzQrCMAzH732K3KanPYB4EM8i6BN0XWwLWwNJJoj03e3qNhD8Qz7Ixy9xgxWBy%2Btc49tA24IdhEDsiNBhsM9IDI9iolajgxE1UC9mSW6oE6eYfCXs9jOjiGsZXMXeacSrBuTtSpWjJMqTU%2BJtb1Z54SQSfRoxKSiV6wSeUKAgcBnLNeaD%2BabmF2fZy4r8i5NA09AX6srMpri5c4Sms9yY%2FAE1Rc7IGwEAAA%3D%3D&config=H4sIAAAAAAAAA2WRy07DQAxF9%2F2KaNYsgBViS1XBovyDNbkpU%2BYl25EaRfl3JmkSEtjNXNvn%2BtEfqspcxZrXqi%2FP8lHiC7T8DeT58enFPNx13BQcyb%2FDZ7CUhIa8YI5mYgGvlKJIF5VuE8cGEssu68yaLMeQcotJGWaMMkVpEoctyeNCtjvCJiZNPNetqHoJnKFUk9K%2BtZLRCo5oXMQp8ZsnkZODr%2BVfHoOsbpxHqY3qAsYx7FjprJmDw67xbyBP6E8KkF2LZTf6NUr9kuxTEvxZYHDRNd12bJtCZsja5mFxnTC%2FBSvFODmnuvXY2JuwKMt5u3yfJoWQ4lWW88b0EcuBU97YDYfhB0yjMHcgAgAA
SWC Info output
No response
Expected behavior
Actual behavior
Version
1.4.12
Additional context
No response
The text was updated successfully, but these errors were encountered: