-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
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? |
I've been running into this more and more as I work with mixed TS/JS projects. Thanks! |
It is very unreasonable to show only the interface rather than the implementation, because in many cases we want to know the details of the functions we used |
+1 |
@hopper01 please don't write a post with only "+1" . just add a reaction with the smiley face.
But I'm not clear why this one is closed too: We are trying to make VScode better and it's not totally open source(with not-FLOSS). We are like unpaid workers here. Please treat us better. Ignoring is worse than rudeness for me. (By the way contributing to https://vscodium.com/ is an alternative method to push VScode) Since this issue is still open (although under Typescript repo), I'll add my opinion here. With vscode(v1.61.2), there are more than five related options in the right click menu:
And none of these can really go to the corresponding JS file, where the class is really defined. The UI logic shown here is that we can jump to TS declaration file ( Then the "3. Go to Implementations" does show a list to peek, although all items in the list are I'll keep an eye on this issue until we see a solid answer. |
Late to the party here, but isn’t this a duplicate of #6209? |
@andrewbranch I just checked #6209 and I think its basically the same. I can see some new issue coming up once in a while but it seems no one is fixing it. One thing I didn't understand thoroughly is why the repo in vscode redirect us to the Typescript repo. I thought it's more about the vscode functionality, not the language. Is there anything you did blocking the functionality? |
All JS intelligence in VS Code comes from the TypeScript compiler. |
Redirecting this to #6209. The discussion there is active. |
@andrewbranch Thank you! I'm very happy that someone in the team can notice this problem. |
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
typescript
entry inpackage.json
to 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.json
jsconfig.json
entryuseTypeDeclarations
that can be set tofalse
.Current alternative solution for Problem 1 & 2
package.json
Project code
This solution has a few downsides that I am aware of:
Related discussions
The text was updated successfully, but these errors were encountered: