Multiple Components: Augment vue
using declare module 'vue'
instead of declare module '@vue/runtime-core'
(and declare module 'vue/types/vue'
) to avoid compilebreaks
#6199
Labels
Type: Enhancement
Issue contains an enhancement related to a specific component. Additional functionality has been add
vue3-portable
Milestone
Describe the bug
primevue currently augments
vue
types usingdeclare module '@vue/runtime-core'
instead of the supposeddeclare module 'vue'
.This causes weird compilebreaks in combination with other popular packages (like vue-router - see this changelog entry and vue-i18n) that use the correct
declare module 'vue'
to augment vue types.The official documentation states this here how to augment vue types correctly.
This is currently an issue in these components/code locations:
primevue/packages/primevue/src/toastservice/ToastService.d.ts
Lines 42 to 52 in 6e55ee9
primevue/packages/primevue/src/dialogservice/DialogService.d.ts
Lines 29 to 39 in 6e55ee9
primevue/packages/core/src/config/PrimeVue.d.ts
Lines 164 to 178 in 6e55ee9
primevue/packages/primevue/src/confirmationservice/ConfirmationService.d.ts
Lines 30 to 40 in 6e55ee9
Above all of these locations, there is an augmentation
declare module 'vue/types/vue'
which should also be removed as of my understanding.So I would suggest to remove the above code lines (
declare module 'vue/types/vue'
) and instead change thedeclare module '@vue/runtime-core'
locations todeclare module 'vue'
instead.Reproducer
https://stackblitz.com/edit/primevue-4-ts-vite-issue-template-nhn9pu?file=src%2FApp.vue
PrimeVue version
4.0.4
Vue version
4.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
Have a typescript project that uses
vue-i18n
(and potentiallyvue-router
):{{ $t('some.translation') }}
An error like
error TS2339: Property '$t' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { xxxxxxxx: typeof xxxxxxxx; xxxxxxxx: typeof xxxxxx; ... 4 more ...; xxxxxx: typeof xxxxxx; }, ... 17 more ..., {}>'
is logged.Expected behavior
primevue augments
vue
types as described in the official docs usingdeclare module 'vue'
(instead ofdeclare module 'vue/types/vue'
ordeclare module '@vue/runtime-core'
).The text was updated successfully, but these errors were encountered: