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
{{ message }}
Repository navigation
Execution order of static field initialization and static initialization blocks is not kept under target: esnext and useDefineForClassFields: falseΒ #45574
Ron Buckton (@rbuckton) should we consider static initialization blocks incompatible with useDefineForClassFields: false, and/or error when they read static class fields under that setting?
changed the title [-]Execution order of static field initialization and static initialization blocks is not kept under module: esnext and useDefineForClassFields: false[/-][+]Execution order of static field initialization and static initialization blocks is not kept under target: esnext and useDefineForClassFields: false[/+]on Aug 25, 2021
Possibly. Or, we can change the emit for esnext when useDefineForClassFields is false to perform the assignments inside of a static {} block as well. I would caution that we only do that if there's already a static {} block on the class, though, since static {} is only shipping unflagged in the latest v8 currently. That way, you opt-in to using static {} for static field initializers when useDefineForClassFields is false if you're explicitly using the syntax in your class (since you're assumed to be running the code in an engine that supports that syntax).
So, for example, our downlevel emit for the above could be:
Activity
andrewbranch commentedon Aug 25, 2021
Ron Buckton (@rbuckton) should we consider static initialization blocks incompatible with
useDefineForClassFields: false, and/or error when they read static class fields under that setting?[-]Execution order of static field initialization and static initialization blocks is not kept under module: esnext and useDefineForClassFields: false[/-][+]Execution order of static field initialization and static initialization blocks is not kept under target: esnext and useDefineForClassFields: false[/+]rbuckton commentedon Aug 25, 2021
Possibly. Or, we can change the emit for
esnextwhenuseDefineForClassFieldsisfalseto perform the assignments inside of astatic {}block as well. I would caution that we only do that if there's already astatic {}block on the class, though, sincestatic {}is only shipping unflagged in the latest v8 currently. That way, you opt-in to usingstatic {}for static field initializers whenuseDefineForClassFieldsisfalseif you're explicitly using the syntax in your class (since you're assumed to be running the code in an engine that supports that syntax).So, for example, our downlevel emit for the above could be: