microsoft / microsoft/TypeScript
Overload order affects assignability of abstract constructors overloaded with regular constructors in interfaces
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 Search Terms
abstract constructors, constructor overloading, overload order, intersection, type aliases, interfaces, assignability
🕗 Version & Regression Information
- This seems like a bug
- This is the behavior in every version I tried since abstract constructors were added (4.2)
⏯ Playground Link
💻 Code
type C1 = abstract new (a: 1) => 1
type C2 = new (a: 2) => 2
interface A extends C1, C2 {} // Error: Cannot assign an abstract constructor type to a non-abstract constructor type.
interface B extends C2, C1 {} // Ok
declare let a: A
declare let b: B
// These are both effectively abstract
new a(1), new a(2), new b(1), new b(2)
a = b // Ok
b = a // Error: Cannot assign an abstract constructor type to a non-abstract constructor type.
type AbstractFirst = C1 & C2
type AbstractLast = C2 & C1
declare let abstractFirst: AbstractFirst
declare let abstractLast: AbstractLast
// These are assignable to each oher
abstractFirst = abstractLast
abstractLast = abstractFirst
b = abstractFirst // Error: Cannot assign an abstract constructor type to a non-abstract constructor type.
abstractFirst = b // Ok
b = abstractLast // Ok
abstractLast = b // Ok
🙁 Actual behavior
It seems that interfaces with both abstract and regular constructor overloads are only assignable from types with non-abstract first constructor overload.
🙂 Expected behavior
I don't expect any difference here.
Additional information about the issue
No response
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 der verlinkten TypeScript Playground-Reproduktion und vergleiche die Zuweisbarkeit von Interfaces und Schnittmengen, die abstrakte und reguläre Konstruktorüberladungen in beiden Reihenfolgen enthalten. Verfolge die Konstruktorüberladungs- und Zuweisbarkeitsprüfungen des Compilers und überprüfe anschließend, dass das Umkehren der Überladungsreihenfolge die in diesem Beispiel angezeigten Fehler nicht mehr verändert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- 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