microsoft / microsoft/TypeScript
Inherited interface functions cause compile error when interface extensions are reordered.
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 132
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire l’extrait de Playground lié avec TypeScript 3.8.3 et comparez l’ordre d’extension des interfaces défaillant et celui corrigé. Suivez le traitement par le compilateur des membres d’interface hérités et des signatures génériques. Le travail est terminé lorsque les deux fonctions se compilent quel que soit l’ordre d’extension et qu’un test de régression couvre le cas signalé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 35/100