Go to definition for ES6 imports if index.js is omitted

I asked this question on github and received this response from Matt Bierner (Microsoft).

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

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

Adding the above configuration to my jsconfig.json seems to have fixed the issue even though I'm using ES6 import and export syntax.

However this shouldn't be an issue since,

In a jsconfig, the module option only changes how paths are resolved

You can read more about the module setting here


There is another solution (source). Include the following in your jsconfig:

"compilerOptions": {
    "module": "es6",
    "moduleResolution": "node"
},

Changing "module": "es6" to "module": "commonjs" worked for me too, but I prefer to keep module set to es6.