When using "go to definition" on a function which has been imported via ES6, vs code jumps to the import statement at the top of the current file. While this might technically be the definition of that variable, it's not particularly useful, as I have to click again to jump to the actual definition, then go back twice to return. The same applies to the hover preview - it shows the import statement, not the function's original definition. ES6 modules in TypeScript suffer from the same problem.
I think that's the correct behavior, since we can import only a set of features, or even name them (giving alias etc). But you could probably write an extension for making this behavior available automatically.
@buzinas, many languages, including C# have pretty much the same kind of import mechanism, with aliases. When I click "go to definition" I want to see the actual code, not the import. "Go to import" isn't useful - I already have a Home key if I want to scroll to the top and see the imports (which I don't).
I completly agree with @jahewson , the current behavior doesn't make sense and is counter productive. +1 for a fix and not an extension
This is something that's been bugging me for months. While technically correct, it is counter-productive and not very useful as @tomsdev said. At least make it a separate option and make the distinction between "go to declaration" and "go to implementation".
So this change has since been made in the TypeScript SDK. Just use a recent version of TypeScript and set "typescript.tsdk" in settings.json and VSCode will behave as desired.
@jahewson Will it be available in VSCode later?
As far as I know VSCode will use your global version of TypeScript, so if you npm install -g a newer version it should just work.
I'm confused. This works correctly in TypeScript now but what about when I'm developing in ES6? Is that ever going to be fixed since this issue is already closed?
@petmat I am also wondering this too
Most helpful comment
@buzinas, many languages, including C# have pretty much the same kind of import mechanism, with aliases. When I click "go to definition" I want to see the actual code, not the import. "Go to import" isn't useful - I already have a Home key if I want to scroll to the top and see the imports (which I don't).