🔎 Search Terms
decorator class static field
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?useDefineForClassFields=true&target=9&ts=5.4.0-dev.20240130#code/DYUwLgBA8gTglgczgOwIbAGIHssG4BQ+AxsKgM5kQBCqMEA3gL6EBmArskWHFshACYgiACmxYAlA3wRo8JGkw4IAXghiCMmODYw+NGAWb4AAoKLFSFNUvrSIZMKm5EIABw33HziKiJEQFFh0qB4OTnAuALbCkkz4RkS8ZFigAHTAWAjC+qkAFuRQAO7IAAowWK4gMGAAnsIARK714gA01LR5BcVlFVW1DajNbTn5ZEWl5ZXVdfWRzeIEicjJaRlZsIgo6GKdY92TfTNNrbKbCjuj4z1T-fWDJxvy2zi7VwfTDXPiC0A
💻 Code
let OriginalFoo;
class Bar {}
function dec(Foo) {
OriginalFoo = Foo;
return Bar;
}
@dec
class Foo {
static p;
static accessor a;
static m() {}
}
console.log(Bar.hasOwnProperty("p"), Bar.hasOwnProperty("a"), Bar.hasOwnProperty("m"));
console.log(OriginalFoo.hasOwnProperty("p"), OriginalFoo.hasOwnProperty("a"), OriginalFoo.hasOwnProperty("m"));
🙁 Actual behavior
It prints
false, false, false
true, true, true
🙂 Expected behavior
It should print
true, true, false
false, false, true
Additional information about the issue
Per RS: ClassDefinitionEvaluation:
In step 27 the static methods are installed to the original class OriginalFoo.
In step 37 the receiver F is assigned by the decorated class Bar.
In step 40 the static fields and accessors are initialized on the decorated class Bar.
So OriginalFoo should contain all the static methods while Bar should contain all the static fields and accessors.
🔎 Search Terms
decorator class static field
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?useDefineForClassFields=true&target=9&ts=5.4.0-dev.20240130#code/DYUwLgBA8gTglgczgOwIbAGIHssG4BQ+AxsKgM5kQBCqMEA3gL6EBmArskWHFshACYgiACmxYAlA3wRo8JGkw4IAXghiCMmODYw+NGAWb4AAoKLFSFNUvrSIZMKm5EIABw33HziKiJEQFFh0qB4OTnAuALbCkkz4RkS8ZFigAHTAWAjC+qkAFuRQAO7IAAowWK4gMGAAnsIARK714gA01LR5BcVlFVW1DajNbTn5ZEWl5ZXVdfWRzeIEicjJaRlZsIgo6GKdY92TfTNNrbKbCjuj4z1T-fWDJxvy2zi7VwfTDXPiC0A
💻 Code
🙁 Actual behavior
It prints
🙂 Expected behavior
It should print
Additional information about the issue
Per RS: ClassDefinitionEvaluation:
In step 27 the static methods are installed to the original class
OriginalFoo.In step 37 the receiver
Fis assigned by the decorated classBar.In step 40 the static fields and accessors are initialized on the decorated class
Bar.So
OriginalFooshould contain all the static methods whileBarshould contain all the static fields and accessors.