Search code examples
typescriptvisual-studio-code

How can I go to the implementation of something instead of its TypeScript declaration?


When I click an imported variable while holding Cmd on macOS in VS Code (or Ctrl on other platforms), I often end up looking at the TypeScript declaration of that variable.

Is there any way to have VS Code take me to the definition of it instead?

I don't use TypeScript myself, so the feature isn't helpful to me right now.


Solution

  • VSCode was updated to include a new option Go to Source Definition. If the ts source is available and ts is upgraded to > 4.7 and VSCode to > 1.67 it should work.

    Many library authors do not include the ts source code unfortunately. The package often only consists of the compiled *.js files and the *.d.ts definition files. That makes this new feature of VSCode useless for these packages unfortunately.

    This is the original issue: https://github.com/microsoft/TypeScript/issues/6209

    And this is an issue for feedback on the new feature. https://github.com/microsoft/TypeScript/issues/49003