unplugin / unplugin-vue-components

📲 On-demand components auto importing for Vue
https://www.npmjs.com/package/unplugin-vue-components
MIT License
3.68k stars 342 forks source link

fix: extends types to `vue` instead of `@vue/runtime-core` #638

Closed wenfangdu closed 1 year ago

wenfangdu commented 1 year ago

Description

Since many projects don't have @vue/runtime-core installed (pnpm projects in particular), the types generated by unplugin-vue-components won't work. Vue projects do have vue installed and augmenting vue itself is enough to get the types to work with Volar.

Linked Issues

Fixes https://github.com/vuejs/language-tools/issues/3107 Fixes https://github.com/antfu/unplugin-vue-components/issues/355 Fixes https://github.com/antfu/unplugin-vue-components/issues/635

lishaobos commented 1 year ago

regression: https://github.com/antfu/unplugin-vue-components/issues/640

kevinvalk commented 10 months ago

This indeed prevents types from properly showing up in my setup (quite standard, Vue3, up to date Vue language extensions, TS5 but just like #640 I am also using unplugin-auto-import). https://github.com/vuejs/router even has a TODO in their code asking why it is not working with 'vue' (I do not have the answer). https://github.com/vuejs/router/blob/c396d14b57be0da1e3504856e89d282f0666242f/packages/router/src/globalExtensions.ts#L11-L12

Solution so far as to lock to version "0.25.0".

elvisWEB commented 2 months ago

This indeed prevents types from properly showing up in my setup (quite standard, Vue3, up to date Vue language extensions, TS5 but just like #640 I am also using unplugin-auto-import). https://github.com/vuejs/router even has a TODO in their code asking why it is not working with 'vue' (I do not have the answer). https://github.com/vuejs/router/blob/c396d14b57be0da1e3504856e89d282f0666242f/packages/router/src/globalExtensions.ts#L11-L12

Solution so far as to lock to version "0.25.0".

I also encountered the same problem, which took me a lot of time to troubleshoot. I suggest adding an option to control whether to use 'vue' or '@vue/runtime-core'