microsoft / microsoft/TypeScript
Inherited interface functions cause compile error when interface extensions are reordered.
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.8.3
Search Terms:
- Order sensitive Interface Extension
- TS2551
I have two interfaces, one providing the function toJSON(), the other toJSONLD(). I then make an interface that inherits from both of these. Depending on the order in which I place these interfaces, toJSON() and toJSONLD() get detected by intellisense and recognized by the type system, yet are marked as not found by the compiler. Additionally, minor changes to the code (like changing the generic parameter of toJSON) also cause the function to once again be detected properly.
This playground snippet has two interfaces: ThingEventBroken and ThingEventFixed. They are identical, and only differ in the order in which I specified the inheriting interfaces.
ThingEventBroken throws compile errors when trying to use the two functions, while ThingEventFixed handles them properly.
Additionally, ThingEventLobotomized uses the same interface order as ThingEventBroken, but uses any for the generic parameter to JSONAble. The issue goes away in this case.
Code
Expected behavior:
Functions provided by interface extension should be present regardless of order.
Actual behavior:
Changing the order of the interfaces results in toJSON() and toJSONLD() not being recognized by the compiler, while still being recognized by the type system.
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 lo snippet di Playground collegato con TypeScript 3.8.3 e confronta l’ordine di estensione delle interfacce errato con quello corretto. Traccia la gestione da parte del compilatore dei membri di interfaccia ereditati e delle firme generiche. Il lavoro è completato quando entrambe le funzioni vengono compilate indipendentemente dall’ordine di estensione e un test di regressione copre il caso segnalato.
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
- 35/100