Skip to content

Go to definition sometimes jumps to non JavaScript file #82054

Description

@tschaub
  • VSCode Version: 1.38.1
  • OS Version: macOS 10.14.6

Steps to Reproduce:

  1. Open a JavaScript project with JavaScript dependencies.
  2. Find a function in the project that is defined in one of the dependencies.
  3. Use "Go to Definition" to drill down and find out how that function is implemented.
  4. Sometimes you find what you are looking for: the source of the function. However, sometimes you find a file named something like index.d.ts that is definitely not what you were looking for.

I made two movies of the steps above. In both movies, I'm drilling down three levels: from useMachine to createUseMachine to interpret. In the first movie, I succeed in finding the implementation of interpret. In the second movie, I fail.

Here is the first movie (success):

success

Here is the second movie (failure):
failure

Does this issue occur when all extensions are disabled?: Yes

The behavior I describe above feels like a bug to me. I imagine people who author their projects in TypeScript might call it a feature. But maybe they would admit that the inconsistency (sometimes jumping to a *.js file and sometimes jumping to a *.d.ts file) is unsettling at least. Whether it is a feature or a bug, I'm left with these two questions (which I know are meant for StackOverflow instead of this issue tracker):

  1. As a JavaScript application developer, is it possible to configure VSCode to prefer the JavaScript sources over *.d.ts files in "Go to Definition?"

  2. As a JavaScript library developer, is there anything I can do when publishing my library to make it so users can more easily get to the JavaScript sources and don't accidentally end up jumping to a *.d.ts file?

This "Go to Definition" functionality, IntelliSense more broadly, and all of VSCode are incredible. Thank you so much for your work on them.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*as-designedDescribed behavior is as designedjavascriptJavaScript support issues

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions