Bug Report
🔎 Search Terms
ES2022 class field initialization order
private fields order
useDefineForClassFields false
🕗 Version & Regression Information
- This changed between versions 4.9.5 and 5.0.4
⏯ Playground Link
5.0.4 with runtime error (useDefineForClassFields: false, target: ES2022)
4.9.5 without runtime error (useDefineForClassFields: false, target: ES2022)
💻 Code
classBuzz{wow='one'}classFoo{ #bar =this.buz.wow;constructor(privatebuz: Buzz){}}newFoo(newBuzz())🙁 Actual behavior
With 5.0.4 and useDefineForClassFields: false, target: ES2022 the above code fails in runtime because #bar = this.buz.wow; stays initialized before constructor, this doesn't happen if "normal private" is used (private bar = this.buz.wow;). Such construct works without issues on 4.9.5.
🙂 Expected behavior
The initialization is done in the same way as on 4.9.5.
Bug Report
🔎 Search Terms
ES2022 class field initialization order
private fields order
useDefineForClassFields false
🕗 Version & Regression Information
⏯ Playground Link
5.0.4 with runtime error (useDefineForClassFields: false, target: ES2022)
4.9.5 without runtime error (useDefineForClassFields: false, target: ES2022)
💻 Code
🙁 Actual behavior
With 5.0.4 and useDefineForClassFields: false, target: ES2022 the above code fails in runtime because
#bar = this.buz.wow;stays initialized before constructor, this doesn't happen if "normal private" is used (private bar = this.buz.wow;). Such construct works without issues on 4.9.5.🙂 Expected behavior
The initialization is done in the same way as on 4.9.5.