microsoft / microsoft/TypeScript
TypeScript language service cannot find subclass references/implementation of mixin methods
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.4k
- Merge moyen
- 1 j 19 h
- PR mergées (30 j)
- 117
Description
🔎 Search Terms
mixin mixins reference references implementation implementations find go to goto language service server protocol lsp
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
⏯ Playground Link
💻 Code
type ConstructorType = abstract new (...params: any[]) => any
function FooF<T extends ConstructorType>(Base: T) {
abstract class Foo extends Base {
abstract foo(): void;
}
return Foo;
}
class Bar extends FooF(Object) {
foo() {}
}
🙁 Actual behavior
Note: I noticed this in my editor and not using the TS language service API directly, but I'm assuming the problem is at the Language Service layer
In the TS playground, if you try to "Find All / Go to References", "Rename symbol", or "Find All / Go to Implementation" (in VS Code, for example) for Foo.foo, it won't find/update Bar.foo.
🙂 Expected behavior
I would expect TS to recognize that Bar.foo is a reference/implementation of Foo.foo. Note that TS does correctly require Bar to implement foo, so the compiler already has some idea that they are connected.
I know it's not within the scope of this repo but I'll mention it in case it helps with anything, but FWIW while IntelliJ also fails at finding references/implementations (probably because it defers to the TS Language service), IntelliJ also provides a "Go to Super method" function that does correctly jump from Bar.foo to Foo.foo.
Additional information about the issue
After snooping around the source a little, my guess is that either:
- something around how TS represents mixin classes, as kind of un-named class expressions e.g.
((abstract new (...params: any[]) => Foo) & { prototype: FooF<any>.Foo; }) & Tinstead oftypeof Foo & Tin the above example (visible if you hover overFooF), and/or - something around how TS searches for whether a symbol inherits from another symbol so explicitly checks the extends clause (https://github.com/microsoft/TypeScript/blob/2e58032f067fbe0d6efbdc970b54b6d72c349aa8/src/services/findAllReferences.ts#L2283-L2302) could be improved
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 la reproduction dans Playground et la logique de recherche d’héritage référencée dans src/services/findAllReferences.ts, autour des lignes 2283-2302. Étudiez comment les classes mixin sont représentées et comment le Language Service recherche les symboles hérités. Le travail est terminé lorsque Find All/Go to References, Rename symbol et Find All/Go to Implementation relient Foo.foo à Bar.foo.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- developer-experience, tooling
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100