microsoft / microsoft/TypeScript
Missing error on class extending union of incompatible constructor types
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
TypeScript Version: 4.2.0-dev.20210105, worked in v3.6.3, regressed in v3.7
Search Terms: is not a constructor function type
Expected behavior:
Error: Type 'typeof Base | typeof Base2' is not a constructor function type.
Or super should not be inferred as any.
Actual behavior:
No error and super: any
Related Issues:
Code
class Base {
prop = 1;
}
class Base2 {
other = 1;
}
const base = Boolean() ? Base : Base2;
class Derived extends base { // ExpressionWithTypeArguments is inferred as 'any', expected error "Type 'typeof Base | typeof Base2' is not a constructor function type."
static fn() {
super.wargarbl.wat; // super is inferred as 'any'
}
fn() {
super.wargarbl.wat; // super is inferred as 'any'
}
}
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": 2,
"target": "ES2017",
"jsx": "React",
"module": "ESNext"
}
}
Playground Link: Provided
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 TypeScript-Codebeispiel und dem zugehörigen Playground-Link und vergleiche das gemeldete Verhalten zwischen den Versionen 3.6.3, 3.7 und 4.2.0-dev. Reproduziere die fehlende Diagnose für class Derived extends base und überprüfe, dass die inkompatible Konstruktor-Union abgelehnt wird, ohne super als any zu inferieren.
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
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100