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

Go to definition doesn't work #19672

Closed
ghost opened this issue Feb 1, 2017 · 11 comments
Closed

Go to definition doesn't work #19672

ghost opened this issue Feb 1, 2017 · 11 comments
Assignees
Labels
*as-designed Described behavior is as designed javascript JavaScript support issues

Comments

@ghost
Copy link

ghost commented Feb 1, 2017

I cannot check the imported modules code for some reason. Go to definition doesn't work or simply jumps to index.d.ts instead.

image

  • VSCode Version: Code 1.8.1 (ee428b0, 2016-12-19T14:42:49.304Z)
  • OS Version: Darwin x64 16.3.0
  • Extensions:
Extension Author Version
EditorConfig EditorConfig 0.3.4
code-settings-sync Shan 2.4.3
jsx TwentyChung 0.0.1
html-css-class-completion Zignd 1.0.3
html-snippets abusaidm 0.0.18
project-manager alefragnani 0.13.1
npm-intellisense christian-kohler 1.2.1
vscode-eslint dbaeumer 1.2.2
githistory donjayamanne 0.1.5
vscode-babel-coloring dzannotti 0.0.4
vscode-npm-script eg2 0.1.8
php-intellisense felixfbecker 0.0.12
code-runner formulahendry 0.6.7
rest-client humao 0.12.1
docthis joelday 0.3.10
better-merge pprice 0.5.1
vscode-icons robertohuertasm 7.1.2
sass-indented robinbentley 1.3.0
annotator ryu1kn 0.10.1

@waderyan waderyan added javascript JavaScript support issues code-navigation labels Feb 1, 2017
@mjbvz mjbvz added the info-needed Issue requires more information from poster label Feb 2, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Feb 2, 2017

Can you please provide some example code or an example project that shows this problem so that we can investigate this.

@ghost
Copy link
Author

ghost commented Feb 4, 2017

import { Link } from 'react-router';

export default (props) => {
    return (
        <h1>{"Hello world!"}</h1>
    );
};

Clicking CMD+ left click on 'React' for example guide us to index.d.ts.

In WebStorm on the other hand we're sent to source code of react.js.

@mjbvz mjbvz added *as-designed Described behavior is as designed and removed info-needed Issue requires more information from poster labels Feb 6, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Feb 6, 2017

This is currently as designed. Our JavaScript language support is powered by TypeScript and the way that TypeScript is able to provide rich support for JavaScript libraries is by using *.d.ts files. That's where it picks up the type info, not from the source itself. If a library is written in TypeScript, then we can jump to the implementations but not if it is written in JavaScript.

I believe that TypeScript is tracking the ability to jump to an JavaScript implementation here: microsoft/TypeScript#6209

@mjbvz mjbvz closed this as completed Feb 6, 2017
@waynebloss
Copy link

I'm sufficiently frustrated by this issue to tell you why: "Go to definition" is such a basic feature and you guys won't just figure out a way to get it done. Instead, you're pointing us to a 1.5 year old TypeScript issue that got removed from their road map as soon as the TypeScript implementation was finished.

This has got to be one of the issues that keeps many people from using vscode because it makes me think that you don't care about the actual work that I need to do with this tool.

IMO, you guys should be on fire for this issue. At the very least, hack together a plugin to cover the most basic scenario (navigating to the node_modules sub-folder that contains the package name under my cursor in an import statement). So, to illustrate:

import React from 'react'; // [B]

class Thing extends React.Component { // [A]
  render() {
    return <div>Thing</div>;
  }
}
  • If I were on the line marked [A] in the example above, with my cursor on React.Component...pressing F12 would bring me to the import statement (the line marked [B]). This is normal vscode behavior and it works.
  • However, if I were on the line marked [B], with my cursor on 'react'...pressing F12 should at least navigate the Explorer sidebar to the proper node_modules/react folder.

If that's all you can do for now - it's better than nothing.

See also: #25197

@unusualbob
Copy link

I have to agree, I'm trying to switch to vscode as its much faster than webstorm, but the fact that I can't navigate code removes 90% of the reason I use an editor. I can't even jump to declarations that are in the same file sometimes and there's no explanation given.

Version 1.11.2
OS: OSX

The code for the project I'm working on unfortunately cannot be shared.

@srgroves
Copy link

I'm also wondering why this issue was closed. "Go to definition" does not work even when everything is in Typescript. It's quite frankly bizarre. This is one of the basic features every IDE should have.

@chaosforfun
Copy link

i need this feature

@SevenZark
Copy link

I need this too. For me it doesn't even work within the same file, and as others have said here, it's a very basic, essential feature in an editor. I've been impressed with VS Code, but this is a deal-breaker, and it's also discouraging to see this issue closed, leading me to think the maintainers of the project just don't care what people need.

@mliq
Copy link

mliq commented Oct 27, 2017

I am working a project with no TypeScript, and adding this to settings solves for me:

"typescript.disableAutomaticTypeAcquisition": true

(it still goes to d.ts files when they exist in a node_module, but otherwise it takes me to the .js definition as desired, instead of an auto-generated d.ts file)

@jabsatz
Copy link

jabsatz commented Nov 2, 2017

I was initially very happy with vscode, and still somewhat are, but this is definitely the most frustrating issue I've come across. I need this fixed, please

@yklykl530
Copy link

me too, may be there is a config to define how is go to defined work

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

10 participants