microsoft / microsoft/TypeScript
Inherited interface functions cause compile error when interface extensions are reordered.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza reproduciendo el snippet enlazado de Playground con TypeScript 3.8.3 y compara los órdenes de extensión de interfaces incorrecto y corregido. Traza cómo el compilador procesa los miembros de interfaz heredados y las firmas genéricas. Se considera terminado cuando ambas funciones compilan independientemente del orden de extensión y una prueba de regresión cubre el caso informado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 35/100