GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enable Go to Implementation in Typescript Editors · Issue #6209 · microsoft/TypeScript

Enable Go to Implementation in Typescript Editors #6209

New issue
Copy link
New issue
Copy link
Closed
#48264
Closed
Enable Go to Implementation in Typescript Editors#6209
#48264
Copy link
Assignees
andrewbranch
Labels
Domain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptDomain: LS: Symbol NavigationRelates to go-to-definition, find-all-references, highlighting/occurrences.Relates to go-to-definition, find-all-references, highlighting/occurrences.Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.SuggestionAn idea for TypeScriptAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issueThere is a VS Code equivalent to this issue
Milestone
TypeScript 4.7.0

Description

@doliver3
doliver3
opened on Dec 22, 2015
Issue body actions

Could you provide a way for Typescript Editors to list the implementations of a type?
This would definitely help developer productivity to be able to find implementations of types faster.

For example, in the Atom Editor atom-typescript plugin you can press F12 to 'Go to Declaration' which as currently implemented you often arrive at the typescript .d.ts file which has the function signature but not the actual implementation.

Since the Typescript parser often generates the d.ts files from the .ts implementation files. Could that association between the d.ts and .ts files be preserved (perhaps output with a typescript compiler option) so that Typescript editors could take developers to a list of the implementing classes or functions?

I opened a similar request for the Atom-typescript editor, but they indicate that they cannot implement this without Typescript parser support:
TypeStrong/atom-typescript#790

Reacted by Ben Creasy, Alexandru Ciucă, mazamachi, David Daniel, Bruno Jouhier, efokschaner, doomleika, Yuya Tanaka, Yuval Greenfield, Nikolaos Tsokos and 387 more
Reacted by Ivan Ilinykh, phatmann, Ray Lee, Peter Ruibal, James Francis, Stephen Brown-Bourne, Scott Tolinski, Sathish, Thomas Pischulski, Luke O'Malley and 40 more
Reacted by Maximilian Beck, Manuel Figueroa, It's me, Ivan Ilinykh, hash, phatmann, Ray Lee, Brian Nelson, James Francis, Stephen Brown-Bourne and 29 more
Reacted by Denis, Stephen Brown-Bourne, Scott Tolinski, Thomas Pischulski, Jacob M-G Evans, Zach Brogan, Carlos Pérez Gutiérrez, Wendell Misiedjan, IBRAGIM (PARVIZ BEKLIEV), disfated and 21 more

Activity

Next
  1. DanielRosenwasser commented on Dec 22, 2015

    @DanielRosenwasser
    Daniel Rosenwasser (DanielRosenwasser)
    on Dec 22, 2015
    Member
    More actions

    So you want this functionality to jump to the corresponding .js if available, provided that the definition is ambient, correct?

    Reacted by Morten Christensen, Nikolaos Tsokos, Bruno Lemos, Viral Shah, Oleg Bilyk, mrbone, Sam Richards, Remco Haszing, Aneil Mallavarapu, Dusan Kovacevic and 70 more
  2. Daniel Rosenwasser (DanielRosenwasser)
    added
    SuggestionAn idea for TypeScriptAn idea for TypeScript
    Domain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScript
    on Dec 22, 2015
  3. DanielRosenwasser commented on Dec 22, 2015

    @DanielRosenwasser
    Daniel Rosenwasser (DanielRosenwasser)
    on Dec 22, 2015
    Member
    More actions

    Ryan Cavanaugh (@RyanCavanaugh) Sara Itani (@mousetraps) Bowden Kelly (@bowdenk7)

  4. doliver3 commented on Dec 23, 2015

    @doliver3
    doliver3
    on Dec 23, 2015
    Author
    More actions

    So you want this functionality to jump to the corresponding .js if available, provided that the definition is ambient, correct?
    Yes this is a scenario that would be very useful for productivity. This alone would be very valuable. I believe the atom-typescript author believes more hooks in the Typescript compiler would make it easier for him to implement this. I'm unclear on whether this is information on js implementation line numbers is information the typescript compiler would typically know internally.

    In addition, another scenario would be enabling a jump to the original typescript .ts file definition in the library being used by the application. I would imagine this information is available pre-compile to d.ts and .js files. We now have entire sets of libraries being written in .ts files as source outputting ES5 syntax js. It would be nice to achieve the ability to jump to the original typescript implementation definition in the .ts files.

    I'm aware this is asking even more to jump to the .ts file implementation in the required library as it might need source map usage or distribution of source/link to original ts source. It would seem to me that the typescript compiler that generates the initial library of functions and classes would know the lines where the implementation is at and could preserve the line numbers when the library is distributed somehow so that the typscript compiler of the application using the class could know what line to jump to in the library.

    Is this information on line number of implementing function/class available in source maps? Are there other sources of this information?

    Reacted by Alex Landau, Yuval Greenfield, Eric Anderson, David Edey, youssefabidi, Jannik Buschke, Andrey, fisherpro, Pavel Horal, Warren Falk and 18 more
  5. Daniel Rosenwasser (DanielRosenwasser)
    added
    Visual StudioIntegration with Visual StudioIntegration with Visual Studio
    and removed
    Visual StudioIntegration with Visual StudioIntegration with Visual Studio
    on Dec 23, 2015
  6. DanielRosenwasser commented on Dec 23, 2015

    @DanielRosenwasser
    Daniel Rosenwasser (DanielRosenwasser)
    on Dec 23, 2015
    Member
    More actions

    Given that we are going to be using the --allowJS flag, the language service should be able to work with the JS files.

    I don't know how .d.ts files and .js files currently work together in that respect. Sheetal Nandi (@sheetalkamat) probably (definitely) knows more about this than I do.

  7. Mohamed Hegazy (mhegazy)
    added
    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.
    on Jan 4, 2016
  8. Wade Anderson (waderyan)
    added
    VS Code TrackedThere is a VS Code equivalent to this issueThere is a VS Code equivalent to this issue
    on Sep 14, 2016
  9. Mohamed Hegazy (mhegazy)
    added this to the TypeScript 2.1 milestone on Sep 15, 2016
  10. Mohamed Hegazy (mhegazy)
    removed
    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.
    on Sep 15, 2016
  11. Richard Knoll (riknoll)
    closed this as completedin #10482on Sep 15, 2016
  12. Richard Knoll (riknoll)
    reopened this on Sep 15, 2016
  13. riknoll commented on Sep 15, 2016

    @riknoll
    Richard Knoll (riknoll)
    on Sep 15, 2016
    Member
    More actions

    Reopening, because going to js files isn't supported quite yet

    Reacted by IBRAGIM (PARVIZ BEKLIEV), disfated, David Peherstorfer, paul-b, evans, gukandrew, Lauro Araujo (Myplanet), joseph-of-wheel, Diego Camacho, major-mann and 5 more
  14. 129 remaining items

  15. andrewbranch commented on Jan 21, 2022

    @andrewbranch
    Andrew Branch (andrewbranch)
    on Jan 21, 2022
    Member
    More actions

    Daniel Iser (@danieliser) totally agree—however, if we get a solution to this at all, it’s likely to be a “best guess” effort to find the corresponding JS from the typings. I’m ok with providing a go-to function for that because it’s better than nothing, but I don’t think we’ll achieve high enough confidence (or satisfactory performance) in that guess in order to pull in the JSDoc. This seems like a case where the answer is just to get the package authors to copy the JSDoc comments to the typings (or copy it in a DT PR). If the typings are generated from TS source, the comments will be copied to the typings automatically. If they’re missing, it means someone’s manual process or third-party tooling is insufficient and the problem should be addressed there.

  16. Andrew Branch (andrewbranch)
    added
    Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
    on Jan 21, 2022
  17. Andrew Branch (andrewbranch)
    self-assigned this
    on Jan 21, 2022
  18. Andrew Branch (andrewbranch)
    modified the milestones: Backlog, TypeScript 4.7.0 on Jan 21, 2022
  19. andrewbranch commented on Jan 21, 2022

    @andrewbranch
    Andrew Branch (andrewbranch)
    on Jan 21, 2022
    Member
    More actions

    Please note the milestone change means I plan to investigate solutions to this during the 4.7 timeframe. I don’t think we have a clear path yet, so it doesn’t necessarily mean that something will ship in 4.7.

    Reacted by Anton Bessonov, Remco Haszing, Scott de Jong, Guy Carmeli, Jérôme, Aliaksei Kislou, Jonathan Rico, Bal Krishna Jha and urielvan
  20. mhofman commented on Jan 28, 2022

    @mhofman
    Mathieu Hofman (mhofman)
    on Jan 28, 2022
    More actions

    I'd like to add a use case: some of our files are authored as .js files (with JSDoc style typing) with explicit/manual .d.ts files for them to express things that cannot be expressed otherwise in JSDoc (e.g. circular type definitions, function overloads, interface, etc.)

    The problem is that with such files, it's impossible to "go to definition" / "go to implementation" as VS Code and other editors stop at the .d.ts file. declarationMap isn't an option since the .d.ts file is manually authored.

    Reacted by Andrew Branch, Malcolm, Micah Engle-Eshleman, Turadg Aleahmad and Ell Bradshaw
  21. TypeScript Bot (typescript-bot)
    added
    Fix AvailableA PR has been opened for this issueA PR has been opened for this issue
    on Mar 14, 2022
  22. andrewbranch commented on Mar 15, 2022

    @andrewbranch
    Andrew Branch (andrewbranch)
    on Mar 15, 2022
    Member
    More actions

    I have a prototype up at #48264 that I’m welcoming feedback on. I’m 100% sure it doesn’t cover everything but if folks are willing to give it a try, it would be helpful to gather some test cases that don’t work yet so I can see if there’s a good way forward on them.

    To try it: There’s a build from TypeScript Bot (@typescript-bot) on the PR (copied below) that you can npm install, then ensure your VS Code window is using that build of TypeScript by opening the command palette (in a TS or JS file) and running TypeScript: Select TypeScript Version. You should see the one newly in your node_modules listed as version 4.7.0. At that point, your Go To Definition command will be replaced with the new logic that finds more JS files and ignores .d.ts files. 🚨 This is not the final experience! We are not replacing Go To Definition like this! We don’t know for sure yet where the new logic will be exposed: it might be in a new command, or its results might be merged into Go To Definition or Go To Implementation. There are technical and UX reasons why the latter might not be desirable, but if it’s in a new command, none of you would be able to test it right now without also running a custom build of VS Code. So this build temporarily replaces the existing go-to-def implementation with the new command so you can easily test it.

    One specific thing to keep an eye out for in testing: There are some cases where we are quite confident in the results we return, other cases where the best we can do is jumping to the top of a file, and then other cases where we’re confident about the file but we make a number of guesses within the file. Under the hood, I am indicating whether or not the result is a guess, but this information isn’t currently exposed in VS Code. If we go forward with presenting guesses like this, it will almost certainly go along with some kind of visual indicator noting that it’s a guess. Here’s an example on import { add } from "lodash":

    image

    Two of these guesses are right, while the top one is wrong. If you notice more places containing wrong guesses like this, please note that and tell me how to repro them on the PR. I need a bit of crowdsourcing to determine whether the guesses are worth doing at all and if there’s an easy way to improve them.

    Thanks all!

    Hey Andrew Branch (@andrewbranch), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

    {
        "devDependencies": {
            "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/122072/artifacts?artifactName=tgz&fileId=F1B646030001FF6586C865D86A3B212F194CAFCD7C9C74E8E24C4BEC6A44B7E502&fileName=/typescript-4.7.0-insiders.20220316.tgz"
        }
    }
    

    and then running npm install.

    Reacted by Philip Waritschlager, Toni Villena, Guy Carmeli, David Luzar, Giora Guttsait, DaviDevMod and Alexei
    Reacted by Valentin Hăloiu, Toni Villena, Guy Carmeli, Giora Guttsait and DaviDevMod
    Reacted by Teje Sczeponek, christophe geiser, Valentin Hăloiu, Philip Waritschlager, Toni Villena, Guy Carmeli, David Luzar, Pob, electron-space, Logan Houp and 3 more
    Reacted by Guy Carmeli, Alexander Genin, Turadg Aleahmad, Giora Guttsait, Marek Krajčovič and DaviDevMod
  23. Andrew Branch (andrewbranch)
    closed this as completedin #48264on Apr 14, 2022
  24. andrewbranch commented on Apr 14, 2022

    @andrewbranch
    Andrew Branch (andrewbranch)
    on Apr 14, 2022
    Member
    More actions

    The plan is to add an experimental new command in VS Code to trigger the behavior added in #48264. I’ll keep this thread updated to let you know when you can try it out in VS Code Insiders + typescript@next.

    Reacted by Andrii Dieiev, Mathieu Hofman, Lauren Yim, Justin Grant, Remco Haszing, disfated, Danizord, Sebastian Andil and marcelmanz
    Reacted by Andrii Dieiev, parksj10, Remco Haszing, disfated, Danizord and Silver Zachara
  25. justingrant commented on Apr 15, 2022

    @justingrant
    Justin Grant (justingrant)
    on Apr 15, 2022
    Contributor
    More actions

    Great progress here. Thanks Andrew Branch (@andrewbranch) for your perseverance in making this happen! Can't wait to try it out.

    Reacted by Andrew Branch, Guy Carmeli, Zach Wegrzyniak and DaviDevMod
  26. andrewbranch commented on May 6, 2022

    @andrewbranch
    Andrew Branch (andrewbranch)
    on May 6, 2022
    Member
    More actions

    I’ll keep this thread updated to let you know when you can try it out in VS Code Insiders + typescript@next.

    I forgot 🤦‍♂️

    You can try this in VS Code Insiders and typescript@next! And pretty soon it will be in the stable versions. I started an issue to gather feedback: #49003. Thanks!

    Reacted by ThaJay
    Reacted by Silver Zachara and Guy Carmeli
  27. selrond commented on May 9, 2022

    @selrond
    Sebastian Andil (selrond)
    on May 9, 2022
    More actions

    Already in the newest release: Visual Studio Code April 2022

    Reacted by Andrew Branch, Guy Carmeli, ThaJay, ouweiya, Hugo Nasciutti and Yush G
    Reacted by ThaJay, Míla Kuchta and Hugo Nasciutti
    Reacted by Silver Zachara, Guy Carmeli, ThaJay, David Marshall, Terence, Hugo Nasciutti, Jean Claveau, kaspar poland and Kevin Moritz
    Reacted by Petr Krejcik, Maxime, ThaJay and Hugo Nasciutti
    Reacted by ThaJay
  28. shayded-exe commented on May 17, 2022

    @shayded-exe
    SHAYDED (shayded-exe)
    on May 17, 2022
    More actions

    Andrew Branch (@andrewbranch) Thank you thank you thank you for making this happen! You just made my life so much easier

    Reacted by Andrew Branch and Hugo Nasciutti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @andrewbranch
    Andrew Branch (andrewbranch)

Labels

Domain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptDomain: LS: Symbol NavigationRelates to go-to-definition, find-all-references, highlighting/occurrences.Relates to go-to-definition, find-all-references, highlighting/occurrences.Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.SuggestionAn idea for TypeScriptAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issueThere is a VS Code equivalent to this issue

Type

No type

Projects

No projects

    Milestone

    • TypeScript 4.7.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.