declare module 'vue' breaks types for auto imported components #2729
-
ReproductionN/A Steps to reproduce the bug
declare module 'vue' {
export interface GlobalComponents {
...
}
}
Expected behaviorIt should not break the types for global components. Actual behaviorBreaks the types for global components Additional informationI am pretty sure this is the change that broke this in our project: We use https://github.com/unplugin/unplugin-vue-components and the types it generates seemingly conflict with the ones Pinia declares. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 19 replies
-
In the ecosystem we were using |
Beta Was this translation helpful? Give feedback.
-
I've been in a similar situation |
Beta Was this translation helpful? Give feedback.
-
We are running on the latest TS version (5.5.4) but the issue is there after i update Pinia. The only deps that are not up to date seem unrelated to this issue. I have listed them below. dev deps:
deps:
|
Beta Was this translation helpful? Give feedback.
-
I think the key here is the use in combination with unplugin-vue-components or unplugin-auto-import. the generated component.d.ts file contains something around the following, then: ...
export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
MyComponent: typeof import('./components/MyComponent.vue')['default']
MyOtherComponent: typeof import('./components/MyOtherComponent.vue')['default']
...
} In my case - the update in the dependabot group broke all type-checks. edit while not a good, minimal reproduction (it's just my project breaking) - this PR showcases that the update of pinia breaks check-types (Ci is passing on main): Also noteworthy: the type-check failures are not due to pinia usage, but due to random, other, auto-imported utility functions. (which in hindsight, would make it more reasonable that it's acutally conflicting with |
Beta Was this translation helpful? Give feedback.
-
Probably unrelated, but in your project, you should try out upgrading the moduleResolution to Bundler: https://github.com/freqtrade/frequi/blob/main/tsconfig.json#L8 I tested locally by adding unplugin-vue-components to https://github.com/posva/demo-data-loaders-artwork-gallery, and it works, so I think you have something in your TS config breaking it. I'm moving this to a question so anybody can try to figure it out and propose and answer |
Beta Was this translation helpful? Give feedback.
BTW: updating vue-router's d.ts to also use
declare module 'vue'
makes everything work. Using multipledeclare module
at the same time like auto imports breaks the in template auto imports.Edit: released vue-router with the update and it's fixed