Bug Report
π Search Terms
decorator static usedefineforclassfields
π Version & Regression Information
- In the Playground, this behaviour first appears in 3.7.5.
β― Playground Link
Playground link with relevant code
π» Code
function foo(ctor: Function) {}
@foo
class C {
static X = 1;
static Y = C.X;
}
π Actual behavior
When targeting esnext, the useDefineForClassFields option is set by default. Using this combination of options, class C is emitted as follows:
let C = C_1 = class C {
static X = 1;
static Y = C_1.X;
};
The name mangling to C_1 causes the assignment to Y to fail at runtime.
If the decorator is removed, the emit becomes:
class C {
static X = 1;
static Y = C.X;
}
which works fine.
If useDefineForClassFields is disabled, the property assignment gets moved outside the class definition, where the name mangling is correct.
π Expected behavior
Probably just not performing the name mangling when emitting within the class.
I appreciate the decorator functionality is unstable, so please consider this bug report purely informational.
Bug Report
π Search Terms
decorator static usedefineforclassfields
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
When targeting
esnext, theuseDefineForClassFieldsoption is set by default. Using this combination of options, class C is emitted as follows:The name mangling to
C_1causes the assignment toYto fail at runtime.If the decorator is removed, the emit becomes:
which works fine.
If
useDefineForClassFieldsis disabled, the property assignment gets moved outside the class definition, where the name mangling is correct.π Expected behavior
Probably just not performing the name mangling when emitting within the class.
I appreciate the decorator functionality is unstable, so please consider this bug report purely informational.