Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ: Jump to declaration in node modules when TypeScript community stubs are present?

In IntelliJ (and WebStorm), when working on a JavaScript project (React, NPM), you can have the IDE download TypeScript community stubs in Preferences | Languages & Frameworks | JavaScript | Libraries. They allow the editor to provide Parameter info to you.

However, when enabled, Go To | (Type) Declaration or Go To | Implementation(s) always jumps to the library's corresponding index.d.ts file in External Libraries | @types - which isn't exactly useful when you are looking for documentation, comments, or implementation details.

Is there a way to support Parameter info but at the same time jump to the right location in node_modules/ when using the Go To context menu command (or make the Quick Documentation work)?

like image 698
Christian Avatar asked Oct 28 '25 18:10

Christian


1 Answers

Current behavior depends on a way d.ts files are defined and included.

  • type definitions, if available, are always used for completion

  • If type definitions are installed in the @types folder, IDE will try to navigate to the JavaScript sources of the library when using Navigate | Declaration. 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 all symbols in d.ts are defined as types or interfaces, that makes it impossible to map them to the actual code.

  • If type definitions are available inside the module (included in npm module distribution), IDE will not index the JavaScript sources by default and, thus, will not be able to navigate to them. To index these files, please use Navigate | Implementation first and answer Yes when the question pops up:

enter image description here

like image 89
lena Avatar answered Oct 30 '25 07:10

lena