microsoft / microsoft/TypeScript
abstract class prototype type has abstract methods even though they are not on the prototype
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Bug Report
🔎 Search Terms
abstract, prototype, type
🕗 Version & Regression Information
All versions I tried
⏯ Playground Link
Playground link with relevant code
💻 Code
abstract class AnAbstract {
public abstract abstractMethod(): void;
public nonAbstractMethod(): void {
// do something
}
}
// no type error - undefined
console.log(AnAbstract.prototype.abstractMethod);
// no type error - false
console.log(AnAbstract.prototype.hasOwnProperty('abstractMethod'));
// defined
console.log(AnAbstract.prototype.nonAbstractMethod);
// true
console.log(AnAbstract.prototype.hasOwnProperty('nonAbstractMethod'));
🙁 Actual behavior
Abstract class prototype has abstract methods in the type
🙂 Expected behavior
Abstract class prototype to have only concrete methods in the type
I have a function that manually define methods based on what's in the prototype, unfortunately when I use an abstract class the type doesn't reflect reality.
If that type cannot change it would be great to be able to do something like:
type NoAbstract<T> = {
-abstract [key in keyof T]: T[key];
};
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.
Rechercherichtung
Beginne mit dem verknüpften TypeScript Playground-Beispiel und vergleiche die deklarierte abstrakte Methode mit dem Laufzeitverhalten des Prototyps. Verfolge, wie der Typ des Prototyps einer abstrakten Klasse gebildet wird, und überprüfe anschließend, dass konkrete Methoden weiterhin verfügbar sind, abstrakte Methoden jedoch nicht; das Issue ist abgeschlossen, wenn das gemeldete Beispiel konsistent mit der Laufzeitrealität typgeprüft wird und die relevante Regressionstestabdeckung erfolgreich ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100