Go to definition not working as expected when typescript definitions are included #39215
Comments
|
Duplicate of microsoft/vscode#68782, microsoft/vscode#82054 |
|
@yume-chan Both of these "duplicates" didn't come with any solution. These comments are talking about the problem but nobody reacted. This is a real problem, please read my initial post: as a package publisher, there is NO WAY for me to publish a package where "go to definition" will work correctly for both JS and TS. And there are some solutions that I proposed in my initial post. |
|
@mjbvz This is not a Typescript issue, this is a VS Code issue as far as I am aware |
|
@incorrupt VS Code asks TS where to go in both cases; I believe the bug is on our end |
If both are true, then I can see how this is TS responsibility. What do you have in your mind? |
TLDR; When writing a Typescript package to be consumed by both Javascript and Typescript, "Go to definition" works for one or the other but not for both.
Problem 1
Steps to Reproduce
⌘+click, I am taken to the type declaration. However, I would expect to be taken to the source file and would expect to be taken to type declarations file if I click "Go to type definition".Current solutions
Problem 2
Steps to Reproduce
⌘+click, I am taken to the source file in Typescript. All is good as expected.⌘+click, I am still taken to the Typescript source file. However, this is not an expected behavior as I am coding in Javascript, so if I want to debug the code, I'd be lost and have to learn Typescript and setup a Typescript compiler.The expected behavior should be to take me to the compiled Javascript (which is what I am actually importing in my project).
Currently, there is no way to control this behaviour, because VS Code probably uses the same algorithm to detect type declarations for Javascript and Typescript.
Possible solutions
typescriptentry inpackage.jsonto include type declarations (and maps) to be used only for Typescript. This has the advantage of letting the package publisher decide what they want to do instead of the consumer.jsconfig.jsonjsconfig.jsonentryuseTypeDeclarationsthat can be set tofalse.Current alternative solution for Problem 1 & 2
package.jsonProject code
This solution has a few downsides that I am aware of:
Related discussions
The text was updated successfully, but these errors were encountered: