microsoft / microsoft/TypeScript
Allow extending multiple interfaces with different, but compatible types
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
interface Change {
uid: string;
type: string;
}
interface SomeChangeExtension {
type: 'some';
foo: number;
}
interface SomeChange extends Change, SomeChangeExtension { }
In this example, I was expecting SomeChange to have a type equivalent to:
interface SomeChange {
uid: string;
type: 'some';
foo: number;
}
But it would result in error:
Interface 'SomeChange' cannot simultaneously extend types 'Change' and 'SomeChangeExtension'.
Named property 'type' of types 'Change' and 'SomeChangeExtension' are not identical.
In this case, 'some' is compatible with string if the order of interfaces being extended is respected.
The reason why I want this to be allowed is that, I need to maintain multiple interfaces of the same kind of change during different stages: raw change, change, broadcast change. And having to duplicate part of the "extension" on every of them doesn't look good.
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 riproducendo l'esempio di interfaccia nel TypeScript compiler e analizza come più estensioni di interfaccia controllano i membri con lo stesso nome. Il lavoro è completato quando vengono accettate proprietà compatibili e più specifiche come 'some' e string, mentre le dichiarazioni incompatibili continuano a produrre errori; nell'issue non sono indicati file o test specifici.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100