microsoft / microsoft/TypeScript
static fields should be installed on the decorated class
Offen
@rbuckton arbeitet bereits daran.
Seit 30.1.2024.
Bug
Domain: Decorators
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 Search Terms
decorator class static field
🕗 Version & Regression Information
- This is a crash
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried (after ES decorators are implemented), and I reviewed the FAQ for entries about decorators
- I was unable to test this on prior versions because _______
⏯ Playground Link
💻 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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.