intlify / vue-i18n

Vue I18n for Vue 3
https://vue-i18n.intlify.dev/
MIT License
2.21k stars 337 forks source link

fix: vue-i18n type definition for vue package #1919

Closed BobbieGoede closed 3 months ago

BobbieGoede commented 3 months ago

As discussed in https://github.com/intlify/vue-i18n/pull/1888 we will need this to prevent breaking types!

zyro23 commented 3 months ago

after updating from 9.13.1 to 9.14.0, vue-tsc fails with errors like:

src/views/MyView.vue:69:14 - error TS2339: Property '$t' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { ... 17 more ..., {}>'.

69           {{ $t('foo') }}
                ~~

src/views/MyView.vue:99:20 - error TS2339: Property '$d' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { ... 17 more ..., {}>'.

99                 {{ $d(myDate, 'dateTime') }}
                      ~~

using composition api with vue-3.4.38, typescript-5.5.4, vue-tsc-2.0.29. as far as ide's are concerned, vs code as well as intellij idea show the same errors. anything i am missing? thanks!

BobbieGoede commented 3 months ago

after updating from 9.13.1 to 9.14.0, vue-tsc fails with errors like:

src/views/MyView.vue:69:14 - error TS2339: Property '$t' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { ... 17 more ..., {}>'.

69           {{ $t('foo') }}
                ~~

src/views/MyView.vue:99:20 - error TS2339: Property '$d' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { ... 17 more ..., {}>'.

99                 {{ $d(myDate, 'dateTime') }}
                      ~~

using composition api with vue-3.4.38, typescript-5.5.4, vue-tsc-2.0.29. as far as ide's are concerned, vs code as well as intellij idea show the same errors. anything i am missing? thanks!

This happens when there is a (sub)dependency that is augmenting @vue/runtime-core instead of vue installed in your project, can you check if this is the case?

zyro23 commented 3 months ago

i hope i understood your question correctly - looks like at least these two dependencies are declaring/augmenting @vue/runtime-core:

update: i think both are being worked on:

for the time being, i am fine with staying on vue-i18n-9.13.1 and will wait for the dependencies to align.

thanks again.

BobbieGoede commented 3 months ago

@zyro23 That's correct, sorry for the inconvenience! Let's hope the other dependencies update their types soon 🙏

florianMo commented 3 months ago

For the record, I ran into this issue using https://github.com/vue-final/vue-final-modal 4.5.4 which does this : https://github.com/vue-final/vue-final-modal/blob/6070275fa60b140132d947de11760b5998c1c8f8/packages/vue-final-modal/src/index.ts#L26.

ReindDooyeweerd commented 2 months ago

How to find out which modules exactly are using runtime-core?

Because i found out that vue-responsiveness was referencing to it with grep -r "declare module '@vue/runtime-core'" node_modules/ but even after fixing that package locally i keep running into Property '$t' does not exist on type 'CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, issues.

 grep -r "declare module '@vue/runtime-core'" node_modules/
node_modules//@vue/runtime-dom/dist/runtime-dom.d.ts:declare module '@vue/runtime-core' {
node_modules//@vue/runtime-core/dist/runtime-core.d.ts: * declare module '@vue/runtime-core' {
node_modules//@vue/runtime-core/dist/runtime-core.d.ts: * declare module '@vue/runtime-core' {
node_modules//@vue/runtime-core/dist/runtime-core.d.ts:declare module '@vue/runtime-core' {
grep -r "import '@vue/runtime-core'" node_modules/

Last one returns nothing

hinogi commented 2 months ago

I have this problem in v10.0.0 and pug templates still