Skip to content

Go To Type Definition fails if the identifier is a type name #46627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
justingrant opened this issue Nov 1, 2021 · 1 comment · Fixed by #46714
Closed

Go To Type Definition fails if the identifier is a type name #46627

justingrant opened this issue Nov 1, 2021 · 1 comment · Fixed by #46714
Labels
Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Milestone

Comments

@justingrant
Copy link
Contributor

Bug Report

Go To Type Definition fails if the identifier is a type name. This is confusing. Instead, Go to Type Definition should navigate to the declaration of the type.

I'm filing this bug as requested by @weswigham in #6209 (comment)

🔎 Search Terms

Go To Type Definition

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about Go to Type Definition

⏯ Playground Link

This issue cannot be reproduced in TS Playground because the "Go to Type Definition" context menu is not available in the Playground.

However, reproducing it in VSCode is trivial.

💻 Code

type T = string;
const x: T;
// in VS Code, right click on the second `T` and choose "Go To Type Definition"

🙁 Actual behavior

image

🙂 Expected behavior

Navigates to the declaration of T

@andrewbranch
Copy link
Member

Proposal:

  • if the symbol has a value meaning, then get its type and try to go to that definition (I think this is the only thing that happens now)
  • else, if the symbol has a type meaning, try to go to its own definition
  • else, give up

Not sure why we would just do nothing if the symbol has no value meaning. We could indicate a better error message to be displayed by VS Code, but that would actually be more work than just going to the definition of a type (because it would be a protocol change).

@andrewbranch andrewbranch added Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript labels Nov 1, 2021
@DanielRosenwasser DanielRosenwasser added Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Help Wanted You can do this labels Nov 1, 2021
@andrewbranch andrewbranch added this to the Backlog milestone Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants