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
Both cases are wrong and throw a runtime error because Foo_1 is undefined.
When compiler target is set 2021 then it works because static properties are then initialized after the class has been created, so Foo_1 exists at this point.
When no decorator is used then this also works because then the transpiler does not create a Foo_1 variable and the static initializer uses Foo instead which exists at this point.
🙂 Expected behavior
There should be no undefined error in the generated code. This could be achieved by using Foo in the static initializer instead of Foo_1.
The text was updated successfully, but these errors were encountered:
Bug Report
🔎 Search Terms
static, property, decorator, es2022, undefined
🕗 Version & Regression Information
This is the behavior in every version which supports ES2022 target I tried, and I reviewed the FAQ for entries about "static"
⏯ Playground Link
Playground Link
💻 Code
🙁 Actual behavior
With target 2022 the code compiles to this JavaScript:
Or to this when
useDefineForClassFields
setting is set totrue
:Both cases are wrong and throw a runtime error because
Foo_1
is undefined.When compiler target is set 2021 then it works because static properties are then initialized after the class has been created, so Foo_1 exists at this point.
When no decorator is used then this also works because then the transpiler does not create a Foo_1 variable and the static initializer uses Foo instead which exists at this point.
🙂 Expected behavior
There should be no undefined error in the generated code. This could be achieved by using
Foo
in the static initializer instead ofFoo_1
.The text was updated successfully, but these errors were encountered: