It is possible to jump to TS source files inside node_modules

When I ctrl+click some type definitions that belong to lib present in node_modules, PHPStorm opens some *.d.ts file with type definitions. Is there some way, or maybe plugin, to peek actual typescript (or javascript) sources of libraries?

1 comment
Comment actions Permalink

In JavaScript files:

  • If type definitions are installed in the node_modules/@types folder, IDE tries to navigate to the JavaScript sources of the library when using Ctrl+click. Please note that this only works for symbols that are defined as classes, variables or functions (and not interfaces or types) in the .d.ts file.
  • If type definitions are available inside the module, PhpStorm does not index the JavaScript source by default and, thus, can't to navigate to them. To index these files, please use Navigate | Implementation first and answer Yes when the question pops up:

 



After that, Ctrl+click will try to take you to the library sources. The same limitation regarding the kind of definition in .d.ts applies.

In TypeScript files:

  • Go to declaration will take you to the d.ts file or .ts sources if they could be mapped.
  • Go to implementation will take you to the .js sources of the module if they could be located and mapped.
0

Please sign in to leave a comment.