As explained in #2548, the following code is not correct when useDefineForClassFields: false, the default for targets before ES2021, or when target <= ES2020.
constx=1classC{p=xconstructor(x: string){}}
However, when useDefineForClassFields: true and target >= ES2021, there shouldn't be an error here.
Expected: No error 2301 on private p = x, and p: number
Actual: Error on private p = x and p: any
Edit: @fatcerberus pointed out that the error is only incorrect when useDefineForClassFields: true and target >= ES2021, because downlevel define for class fields still happens in the constructor.
The text was updated successfully, but these errors were encountered:
This is broken because the outer x gets shadowed by the ctor parameter, right? But that means it’s also broken for downleveled useDefineForClassFields too…
As explained in #2548, the following code is not correct when
useDefineForClassFields: false, the default for targets before ES2021, or when target <= ES2020.However, when
useDefineForClassFields: trueand target >= ES2021, there shouldn't be an error here.Expected: No error 2301 on
private p = x, andp: numberActual: Error on
private p = xandp: anyEdit: @fatcerberus pointed out that the error is only incorrect when
useDefineForClassFields: trueand target >= ES2021, because downlevel define for class fields still happens in the constructor.The text was updated successfully, but these errors were encountered: