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 in a Vue SFC file on the import of another Vue component in a library with declaration maps doesn't work #3491

Open
segevfiner opened this issue Aug 19, 2023 · 5 comments
Labels
question Further information is requested

Comments

@segevfiner
Copy link
Contributor

  1. Clone https://github.com/segevfiner/volar-declaration-map-issue
  2. pnpm i
  3. pnpm -r build
  4. Open the project in VS Code.
  5. Open "packages/bar/src/App.vue", and click on HelloWorld in the import on line 3 and go to definition, it goes to the built .d.ts file of HelloWorld.vue.
  6. Open "packages/bar/src/main.ts", and click on HelloWorld in the import on line 8 and go to definition, it goes to the HelloWorld.vue source file.

This seems to happen in both non-takeover and takeover mode.

Related to the previously closed #1344

@so1ve so1ve added the question Further information is requested label Jan 27, 2024
@so1ve
Copy link
Member

so1ve commented Jan 27, 2024

@segevfiner I think this is expected - when importing from foo, you are bundling foo first, then bundle bar, so you are not importing its source, but the build result.

If you want to goto HelloWorld.vue, I suggest you use this: https://www.typescriptlang.org/tsconfig/paths.html

@so1ve
Copy link
Member

so1ve commented Jan 27, 2024

Ah - wait, declaration maps?

@Ping-Gao
Copy link

Ping-Gao commented Feb 4, 2024

I am having this issue as well, declaration maps only worked in ts file but not in vue file.

@Ping-Gao
Copy link

Ping-Gao commented Feb 4, 2024

Ah - wait, declaration maps?

He was talking about this https://www.typescriptlang.org/tsconfig#declarationMap We want to go to source code rather than .d.ts.

@max-220
Copy link

max-220 commented Mar 15, 2024

I noticed that it is caused by an incorrect source file name with .ts extension in e.g. SomeComponent.vue.d.ts.map

It's still reproducible with "vue-tsc": "1.8.27":

{
  "version":3,
  "file": "SomeComponent.vue.d.ts",
  "sourceRoot": "",
  "sources":["../../../../src/components/SomeComponent.vue.ts"], 
                                                          ^^^^
  ...
}
                                                                            

And with "vue-tsc": "2.0.6" it works as expected:

{
  "version":3,
  "file": "SomeComponent.vue.d.ts",
  "sourceRoot": "",
  "sources":["../../../../src/components/SomeComponent.vue"], 
  ...
}
                                                                            

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants