microsoft / microsoft/TypeScript
"Go To Type Definition" for type names should navigate to the type definition
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
"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.
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
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers, developer-experience
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 48/100