-
-
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
Arrow functions as class properties compile incorrectly #3471
Comments
In the provided playground, switching from JavaScript to TypeScript produces correct output! |
see #3268 |
I believe |
No. This is not related to ts nor decorator |
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
When using specific browser target to reduce how much compilation is being applied to the code, an edge case surfaces that incorrectly transpiles arrow functions as class properties, losing the correct reference to
this
. See the attached playground and you'll notice_this.getBar(b)
is referencing_this
which is not a valid reference.Input code
Config
Playground link
https://play.swc.rs/?version=1.2.133&code=H4sIAAAAAAAAA0vOSSwuVnDLz1eo5lJQSE8tcUos0kjSBPMUFIpSS0qL8hSSFLQUjIACtVwQNSDltgoa1UCJWiCjulZTwdYOVUtJRmaxHtw4sF6g7uT8vOIShTSgnrzUcpCtGppgsfycVL2c%2FHSNND2I6SCjrRSMFGo1NQHVZOk3oQAAAA%3D%3D&config=H4sIAAAAAAAAA0WO3QqDMAyFXyUEdidjE9yFbHuDPUSwUTq0lSbKRPrua53Du5Pz85EV39JgveJIQThkJYtT%2BmCN3AwkTbCjYpFqyWqpF44FKoWONVekSlnvvfCeFjhYZ9slkxo%2FjIFFjohc1%2F%2BbMYEGb6ZsrKjLyBvwhvFg7Dsrr72oYUo3u3nbbG8kPD7hci6rE5Az0JMolDBzEOudFOC8gmEyP2UZ7g%2B4XjHGL6hpzCH9AAAA
Expected behavior
this.getBar(b) call should work!
Actual behavior
Error is thrown
Uncaught TypeError: _this.getBar is not a function
, because_this
is not pointing to the class instance.Version
1.2.133
Additional context
No response
The text was updated successfully, but these errors were encountered: