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 for ES6 imports when omitting index from the path. #24715

Closed
BrandonBoone opened this issue Apr 13, 2017 · 3 comments
Assignees
Labels
javascript JavaScript support issues *question Issue represents a question, should be posted to StackOverflow (VS Code) typescript Typescript support issues

Comments

@BrandonBoone
Copy link

  • VSCode Version: 1.12.0-insider
  • OS Version: Windows 7
  • Commit d1b315f
  • Date 2017-04-13T06:10:58.128Z
  • Shell 1.6.6
  • Renderer 56.0.2924.87
  • Node 7.4.0

Steps to Reproduce:

Code

import { member } from './myModule'

Directory Structure: ./myModule/index.js

  1. Right click on member
  2. Click "Go to definition"
  3. The message, "No definition found for 'member'" appears.
  4. Update code to:
import { member } from './myModule/index'
  1. "Go to definition" now works as expected.

gotodefinition

I'm not sure if this is a vscode or a TypeScript specific issue (my understanding is that the TypeScript engine is powering all JS intellisense). Perhaps it can be resolved using some settings in jsconfig.json? Apologize if it's configuration based, but I couldn't find anything in the docs.

The docs on TypeScript's module resolution seem to suggest that this should work without having to explicitly mention the index file in the path: https://www.typescriptlang.org/docs/handbook/module-resolution.html

@mjbvz mjbvz self-assigned this Apr 13, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Apr 13, 2017

Does your project have a jsconfig.json? Can you make sure it contains the setting:

{
  "compilerOptions": {
    "module": "commonjs"
  }
}

@mjbvz mjbvz added javascript JavaScript support issues typescript Typescript support issues labels Apr 13, 2017
@BrandonBoone
Copy link
Author

That worked! Does it matter that I'm using ES6 import and export syntax?

@mjbvz
Copy link
Contributor

mjbvz commented Apr 14, 2017

Not in this case since you are working with JavaScript instead of TypeScript. In a jsconfig, the module option only changes how paths are resolved

@mjbvz mjbvz closed this as completed Apr 14, 2017
@mjbvz mjbvz added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Apr 14, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues *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

2 participants