Skip to content
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

cmd+click skip typescript definition and go to source? #68782

Closed
jsumners opened this issue Feb 15, 2019 · 7 comments
Closed

cmd+click skip typescript definition and go to source? #68782

jsumners opened this issue Feb 15, 2019 · 7 comments
Assignees
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code) typescript Typescript support issues

Comments

@jsumners
Copy link

When I cmd+click on an entity it is supposed to go to the definition of that entity. When said entity is an npm installed module it will go to the source code of that module within node_modules iff the module does not have TypeScript definitions. I cannot read TS definitions and would really rather just go to the source code for the entity I need to learn about. How do I make it so that TS definitions are ignored and I am always taken to the source?

@vscodebot
Copy link

vscodebot bot commented Feb 15, 2019

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@vscodebot vscodebot bot added the typescript Typescript support issues label Feb 15, 2019
@mjbvz
Copy link
Collaborator

mjbvz commented Feb 15, 2019

See https://code.visualstudio.com/docs/nodejs/working-with-javascript#_typings-and-automatic-type-acquisition for why we do this

In general, you cannot jump to the js implementation of a npm module

@mjbvz mjbvz closed this as completed Feb 15, 2019
@mjbvz mjbvz added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Feb 15, 2019
@jsumners
Copy link
Author

I'm sorry. What are you expecting me to learn at that link? I don't care about the typings. I want to see the source code when I try to view the definition.

@RyanCavanaugh
Copy link
Member

It's not that TypeScript types are blocking you from jumping to the implementation, it's that there in general is not logic to examine the code of an arbitrary node module and figure out which external invocations map to which implementations in the module.

@jsumners
Copy link
Author

I fail to understand that. If I have:

const foo = require('foo')

console.log(
  foo.bar()
)

I can cmd+click on 'foo' and be taken to the source of the foo module. As soon as a .ts.d file is present that describes the foo module, by whatever mechanism, then cmd+clicking 'foo' takes me to that .ts.d file instead of the source code. I simply want to ignore that .ts.d file altogether.

@lvl99
Copy link

lvl99 commented Mar 17, 2019

I was just about to report this as a bug as well.

I'm unsure why we can CMD + click on code in JS files and it points us to the entity's assignment/definition within a file in the node_modules folder, however when coding in TS files, CMD + clicking on entities will point to the TS definition. It would be nice to have the difference between viewing the assignment and the type definition (CMD + SHIFT + click to view type definition?).

The extra problem that I have is when using external packages that don't have TS definitions. To get around the TS errors, I'd put in a declare module "package-name" into the globals.d.ts file. This means that CMD + clicking on any entity related to that module will point me to the declare module "package-name" line, and not the actual code in the node_modules folder. Which then means I need to manually search for the code in the node_modules folder, which is quite frustrating!

@jkrems
Copy link
Contributor

jkrems commented Mar 28, 2019

It's not that TypeScript types are blocking you from jumping to the implementation

As others have pointed: This is exactly what is happening though. Jumping to the implementation does work perfectly fine in vscode. Until type definition files enter the picture. Then the only thing that's possible is manually browsing the files and trying to find the implementation the old fashioned way because the type definition file intercepts any attempt to jump to definition using editor commands.

@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code) typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

5 participants