Skip to content

Go to definition for nodejs javascript file broken by existance of .d.ts #38474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Raynos opened this issue May 11, 2020 · 6 comments · Fixed by #48264
Closed

Go to definition for nodejs javascript file broken by existance of .d.ts #38474

Raynos opened this issue May 11, 2020 · 6 comments · Fixed by #48264
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Fix Available A PR has been opened for this issue Suggestion An idea for TypeScript

Comments

@Raynos
Copy link

Raynos commented May 11, 2020

  • VSCode Version: 1.44.2
  • OS Version: Ubuntu

Steps to Reproduce:

  1. Go to a nodejs project that has multiple dependencies in node_modules
  2. Hit go to definition on a javascript require statement
  3. Expect to be taken to javascript source code for that module
  4. Sometimes taken to foreign .d.ts file.

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

Example go to definition that works

uuid-works

Example of go to definition thats broken

promise-broken

Example of go to definition can be made to work for is-promise

The is-promise javascript library has an index.d.ts file which breaks go to definition because it exists.

I can remove this file by running rm node_modules/is-promise/index.d.ts

promise-working

It's really frustrating that go to definition only works if the index.d.ts does not exist.

One work around would be to rm ./node_modules/**/*.d.ts

Possible duplicate

microsoft/vscode#82054

This issue is very similar to the above.

It was closed because

The reason why we cannot jump to 3rd party JS is that JS's dynamic nature makes it impossible

This is not correct, i manually deleted the index.d.ts file from node_modules/is-promise and got exactly the behavior that i wanted.

The vscode go to definition for nodejs javascript works in almost all cases except when a .d.ts file exists.

It would be great if vs code has a flag to ignore *.d.ts files for when going to definition in a javascript project.

@mjbvz mjbvz transferred this issue from microsoft/vscode May 11, 2020
@mjbvz mjbvz removed their assignment May 11, 2020
@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels May 11, 2020
@Raynos
Copy link
Author

Raynos commented May 13, 2020

I am confused why this is a TypeScript issue and not a VS code issue ?

I am trying to use go to definition in VS code for JavaScript.

Is the JavaScript language server and/or go to definition implemented in TypeScript itself ?

Would a syntax highlighting bug in JavaScript in vs code also be a "microsoft/TypeScript" issue ?

Cc @mjbvz

@mjbvz
Copy link
Contributor

mjbvz commented May 13, 2020

The TypeScript language service powers VS Code's JavaScript and TypeScript IntelliSense

Syntax highlighting comes from https://github.com/Microsoft/TypeScript-TmLanguage

@tschaub
Copy link
Contributor

tschaub commented May 14, 2020

It would be great if vs code has a flag to ignore *.d.ts files for when going to definition in a javascript project.

I agree with the suggestion that it would improve the user experience if VSCode had an option to prefer JS sources over *.d.ts files or otherwise allow users to never see a *.d.ts file when going to the definition of a JS function.

@Raynos
Copy link
Author

Raynos commented Oct 16, 2020

I’ve run into this issue again today.

I would like an option to ignore *.d.ts files always go to the definition of the real javascript source code.

@AndreVanKammen
Copy link

AndreVanKammen commented Jan 2, 2021

I'm trying to get Intellisense to work for a javascript project and I'm also running into this issue. Finally got intellisense working but now go to definition ends in the .d.ts files.

@okikio
Copy link

okikio commented Aug 7, 2021

Is there any progress on this?

@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Fix Available A PR has been opened for this issue Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants