Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

"Go to definition" on vue components goes to vue.d.ts #45

Open
ubershmekel opened this issue Apr 27, 2018 · 6 comments
Open

"Go to definition" on vue components goes to vue.d.ts #45

ubershmekel opened this issue Apr 27, 2018 · 6 comments

Comments

@ubershmekel
Copy link

ubershmekel commented Apr 27, 2018

Repro steps:

  1. Clone and npm install this repo
  2. Open index.ts in VS code
  3. Right-click then select Go to Definition on HelloComponent
  4. VS Code opens vue.d.ts. When going to the definition of "./components/Hello.vue" I'm taken to vue-shims.d.ts instead.

Is this a known issue?

@Atuna
Copy link

Atuna commented May 4, 2018

Same here. And I have done some search, I am not sure is this relevant?

This is quite weird, since "Go to definition" works perfectly well in *.vue files.
2018-05-04 15 10 15

@ubershmekel
Copy link
Author

@octref or @HerringtonDarkholme is this a Vetur bug?

@HerringtonDarkholme
Copy link

is this a Vetur bug?

Nope, Vetur cannot handle "jump to definition" in *.ts file.

"Go to definition" works perfectly well in *.vue files.

Vetur can handle definition lookup in vue file, but it cannot hijack the behavior of TS.

I'm taken to vue-shims.d.ts instead.

This is expected. Instead of using vue-shims.d.ts, you can try this TS server plugin. https://github.com/HerringtonDarkholme/vue-ts-plugin

I didn't invest much time in it, but it can handle basic definition lookup as far as I tried.

@ubershmekel
Copy link
Author

Thanks @HerringtonDarkholme ! I'll test that in a bit. I wonder if jumping from a module to its source versus jumping to its type definition is worth supporting in the module declaration syntax itself somehow. @weswigham because you worked on microsoft/TypeScript#6209 I thought you might be able to weigh in.

@weswigham
Copy link
Member

In 2.9 the language service will support reading sourcemaps for .d.ts files to map the results back into another file; that won't help here, though, since the problem arises from how imports from "*.vue" files have a wildcarded definition to a single type in the vue .d.ts. As far as TS is concerned, the .vue files aren't in the build - that's all the vue service (which is probably why it works from vue file to vue file, but not on imports in TS).

@riddla
Copy link

riddla commented Jan 30, 2019

I just wanted to chime in here to say that https://github.com/HerringtonDarkholme/vue-ts-plugin works like a charm for "jump to definition" in VS Code.

Thanks @HerringtonDarkholme 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants