microsoft / microsoft/TypeScript
Intersection type of abstract classes does not throw error if same member exists in multiple abstract classes
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: 3.0.1
Search Terms: "Intersection", "abstract"
Code
export type Constructor<T = {}> = new (...args: any[]) => T;
abstract class Outer1 {
abstract same: number;
abstract notSame: string;
}
abstract class Outer2 {
abstract same: number;
}
function Mixin1<TBase extends Constructor>(Base: TBase) {
abstract class Inner1 extends Base { // Same as Outer1
abstract same: number;
}
return Inner1;
}
function Mixin2<TBase extends Constructor>(Base: TBase) {
abstract class Inner2 extends Base { // Same as Outer2
abstract same: number;
}
return Inner2;
}
function rollUp<T>(mixins): new (...args) => T {
return mixins.reduce((acc, mixin) => mixin(acc), class Seed {});
}
class Example extends rollUp<Outer1 & Outer2>([Mixin1, Mixin2]) {
// Compiler will throw error when "notSame" is unimplemented
// Compiler DOES NOT throw error about non-implemented "same" member
}
Expected behavior:
Compiler should say that same is not implemented in regular class
Actual behavior:
Compiler does not throw error saying that same is not present in example class, despite throwing an error about notSame. It will throw an error, however, if the types of same are incompatible.
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 eseguendo la riproduzione collegata di TypeScript Playground e confronta le diagnosi per same e notSame nella classe Example. Traccia la gestione da parte del compilatore dei membri astratti prodotti dall'intersezione e dai mixin; il lavoro è completato quando viene segnalato il membro same mancante e la diagnosi esistente di notSame rimane corretta.
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
- Abbastanza chiara
- Idoneità per principianti
- 35/100