Open ubershmekel opened 6 years ago
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.
@octref or @HerringtonDarkholme is this a Vetur bug?
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.
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 https://github.com/Microsoft/TypeScript/issues/6209 I thought you might be able to weigh in.
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).
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 👍
Repro steps:
index.ts
in VS codeGo to Definition
onHelloComponent
vue.d.ts
. When going to the definition of"./components/Hello.vue"
I'm taken tovue-shims.d.ts
instead.Is this a known issue?