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

Global component definitions not recognized when declare module 'vue' is defined twice in different files #3383

Closed
innocenzi opened this issue Jul 8, 2023 · 6 comments
Labels
good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first upstream

Comments

@innocenzi
Copy link

innocenzi commented Jul 8, 2023

I'm not sure if the title is the actual explanation of the issue, but that's what I found out while debugging.

Basically, I want to use unplugin-auto-import and unplugin-vue-components in the same project. I generate their .d.ts in a directory, eg. .types.

The issue appears when unplugin-auto-import uses the vueTemplate option. When enabled, it declares ComponentCustomProperties in a declare module 'vue'. When this is the case, global components are no longer detected (marked as unknown).

Reproduction:

  • Clone https://github.com/innocenzi/volar-issue-3383
  • Run nr dev to generate types
  • Go to src/App.vue in VSCode, see that <HelloWorld> is unknown
  • Go to .test/auto-imports.d.ts, remove the entire declare module 'vue' block under // for vue template auto import
  • Restart Volar, and see that <HelloWorld> is now properly recognized
Version: 1.79.2
Commit: 695af097c7bd098fbf017ce3ac85e09bbc5dda06
Date: 2023-06-14T08:58:33.551Z
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4_1) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.79.2 Chrome/108.0.5359.215 Electron/22.5.7 Safari/537.36

Volar: 1.8.4
@so1ve
Copy link
Member

so1ve commented Jul 8, 2023

#3372 #3107

@innocenzi
Copy link
Author

innocenzi commented Jul 9, 2023

Workaround for me was to put the auto-imports.d.ts last in tsconfig.json. Not sure if that has unwanted side-effects yet.

@BTBMan
Copy link

BTBMan commented Jan 24, 2024

I noticed that it always detects the first declare module 'vue', I think it should detect all of it.

@rchl
Copy link
Collaborator

rchl commented Jan 24, 2024

You have to make sure that your declaration is evaluated after the original one. So just reference the original one above yours by importing relevant module. Or otherwise adjust the order of loading.

@BTBMan
Copy link

BTBMan commented Jan 25, 2024

I've adjusted the file order of the tsconfig include field to fix it, This way is so Weird!!!🤔

@johnsoncodehk johnsoncodehk added upstream good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first labels May 13, 2024
@phil668
Copy link

phil668 commented May 20, 2024

Is there any progress?still exists this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first upstream
Projects
None yet
Development

No branches or pull requests

6 participants