microsoft / microsoft/TypeScript

"Go To Type Definition" for type names should navigate to the type definition

Ouverte
#33,147 1 commentaire 2 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Domain: LS: Symbol Navigation In Discussion Suggestion
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
2 j 4 h
PR mergées (30 j)
132

Description

"Go To Type Definition" doesn't doesn't work when the selection is itself a type. Instead, you get a "No type definition found" error. I can understand why it was implemented in this way ("types don't have a type!") but IMHO this behavior unnecessarily inconsistent and confusing for users. If I ask for the type definition of a type, then I should be taken to the... type definition! ;-)

I'm filing this at @weswigham's request to split it out of #6209. IMHO, if #6209 is implemented as I'm suggesting (where Go To Definition would navigate to the actual implementing source, not the DefinitelyTyped .d.ts) then fixing this issue would be helpful because it'd make both operations more consistent:

  • Go To Definition would always navigate to implementation code (not to type declarations), regardless of what symbol is selected.
  • Go to Type Definition would always navigate to type declarations, regardless of what symbol is selected

Search Terms

Go to Type Definition
No type definition found for
getTypeDefinitionsAtPosition - this is one possible method to change in a PR

Suggestion

Go to Type Definition should, when called for a type, return the location of the type definition.

Use Cases

Discussed above

Examples

type X = {a: number};
const a: X = {a: 1};

In VSCode, select and right-click on the second X and choose Go To Type Definition.

Expected: navigates to declaration
Actual: No type definition for 'X'

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Start with the getTypeDefinitionsAtPosition entry point named in the issue and reproduce the example by selecting the type name in the TypeScript language service. Done means Go To Type Definition returns the type declaration for a selected type instead of reporting that no type definition was found.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
compilers, developer-experience
Type d'issue
Fonctionnalité
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.