Intent to Ship: Class Static Initialization Blocks
Class Static Initialization blocks allow JavaScript programmers to run pieces of code during class definition.
class G {
static {
try { this.a = foo(); } catch { this.a = “default” }
}
}
This proposal is at Stage 3 in the TC39 process (https://tc39.es/process-document/)
Meta Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1670018
Ship Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1725689
Proposed Standard: https://github.com/tc39/proposal-class-static-block
Proposal Repository: https://github.com/tc39/proposal-class-fields
MDN: Not yet written I believe.
Platform coverage: all platform, pref on by default
DevTools Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1712173
Other Browsers: Shipping by default in Chrome 91 (Intent to Ship is here: https://groups.google.com/a/chromium.org/g/blink-dev/c/pzy_Z3AwmaY/m/FeXzN3hnAwAJ)
Testing: Test262 Tests: https://github.com/tc39/test262/pull/2968