Skip to content
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

[typescript-language-features] Add command and editor context menu contribution for Find Source Definition #147532

Closed
andrewbranch opened this issue Apr 15, 2022 · 7 comments
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@andrewbranch
Copy link
Member

I was overconfident in my ability to figure out how to expose microsoft/TypeScript#48264 in VS Code 😅, calling on @mjbvz for help. I started copying some relevant stuff about commands and contexts from Find File References, but then I realized the UI behavior I want is identical to definitions/implementations, and I didn’t know how to reconcile those two things.

@mjbvz mjbvz added this to the April 2022 milestone Apr 19, 2022
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 19, 2022

@andrewbranch Can you share the VS Code branch you've been using for testing?

@andrewbranch
Copy link
Member Author

When I was developing microsoft/TypeScript#48264, I just tested with VS Code Insiders by temporarily replacing the implementation of Go To Definition with the implementation of Find Source Definition since the response shape was the same. Now that microsoft/TypeScript#48264 is merged, I don’t have a VS Code branch capable of testing it yet.

@mjbvz mjbvz closed this as completed in d851ea5 Apr 20, 2022
@mjbvz mjbvz added feature-request Request for new features or functionality verification-needed Verification of issue is requested labels Apr 20, 2022
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 20, 2022

@andrewbranch Thanks! Just pushed a fix that should enable this command in two places:

  • Right click in the editor context menu
  • Through the command palette

Notes for testers:

  • Verify that the command only shows up when using TS 4.7+
  • The command should jump to the definition directly if there is a single source definition. Otherwise it should show a list of references
  • If no references are found, we show an error notification. This UX is not ideal. In the future we hope to show an inline notification like find all references does

@andrewbranch
Copy link
Member Author

Thank you @mjbvz! 🌟

@IllusionMH
Copy link
Contributor

Worked well so far for my "weird" cases:

  1. JS project that has separate types folder with declare module 'path/to/js/file' {...} for key files. Correctly navigated to actual JS file (even for exports that are (intentionally) not exported in type declarations).
  2. JS project where jsconfig.json and node_modules are in one folder, however node_modules with corresponding @types packages are couple of levels above. Navigated to correct JS source in node_modules.

@andrewbranch
Copy link
Member Author

Thanks for testing!

@alexr00 alexr00 added the verified Verification succeeded label Apr 26, 2022
@alexr00
Copy link
Member

alexr00 commented Apr 26, 2022

Works great, very useful!

@github-actions github-actions bot locked and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants
@IllusionMH @andrewbranch @mjbvz @alexr00 and others