Bug Report
π Search Terms
decorated class with static field initialization runtime error
π Version & Regression Information
Typescript version 4.6.2
Target: ES2022
Module: ES2022
- This changed between versions 4.5.5 and 4.6.2
β― Playground Link
Playground link with relevant code
π» Code
function decorator(name: string): any {
return () => console.log(name)
}
@decorator("break")
class BreakStatement {
static BreakSymbol = Symbol.for('break');
static BREAK_INSTANCE = Object.freeze(new BreakStatement(BreakStatement.BreakSymbol));
constructor(public symbol: Symbol){}
};
π Actual behavior
- compile successfully and print 'break' at runtime
- at run time

π Expected behavior
no runtime error and print 'break'
execute static BREAK_INSTANCE = Object.freeze(new BreakStatement(BreakStatement.BreakSymbol));
after the decorator applied
OR
execute decorator definition in the first static initialization block
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var BreakStatement_1;
function decorator(name) {
return () => console.log(name);
}
let BreakStatement = BreakStatement_1 = class BreakStatement {
static {
BreakStatement_1 = __decorate([
decorator("break"),
__metadata("design:paramtypes", [Object])
], BreakStatement);
}
symbol;
static BreakSymbol = Symbol.for('break');
static BREAK_INSTANCE = Object.freeze(new BreakStatement_1(BreakStatement_1.BreakSymbol));
constructor(symbol) {
this.symbol = symbol;
}
};

Bug Report
π Search Terms
decorated class with static field initialization runtime error
π Version & Regression Information
Typescript version 4.6.2
Target: ES2022
Module: ES2022
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
π Expected behavior
no runtime error and print 'break'
execute
static BREAK_INSTANCE = Object.freeze(new BreakStatement(BreakStatement.BreakSymbol));after the decorator applied
OR
execute decorator definition in the first static initialization block