microsoft / microsoft/TypeScript
Missing error on class extending union of incompatible constructor types
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con l'esempio di codice TypeScript e il link Playground fornito, confrontando il comportamento segnalato tra le versioni 3.6.3, 3.7 e 4.2.0-dev. Riproduci la diagnostica mancante per class Derived extends base e verifica che l'unione di costruttori incompatibile venga rifiutata senza inferire super come any.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100