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

type error: vue-i18n 9.14.0 breaks $t function in Vue 3.4.38 #1923

Closed
4 tasks done
isamu opened this issue Aug 20, 2024 · 3 comments
Closed
4 tasks done

type error: vue-i18n 9.14.0 breaks $t function in Vue 3.4.38 #1923

isamu opened this issue Aug 20, 2024 · 3 comments
Labels
Status: Review Needed Request for review comments

Comments

@isamu
Copy link

isamu commented Aug 20, 2024

Reporting a bug?

When updating vue-i18n from version 9.13.1 to 9.14.0, the $t function, which is used for translation, no longer works correctly in a Vue 3.4.38 project. The following error is displayed

ERROR(vue-tsc)  Property '$t' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; default: string; }; }>>, unknown, unknown, {}, {}, ComponentOptionsMixin, ... 13 more ..., { ...; }>'.

Expected behavior

The $t function should work as expected, allowing for translations without any TypeScript errors or runtime issues, just as it does in vue-i18n version 9.13.1.

Reproduction

  • Install vue-i18n version 9.14.0 in a Vue 3.4.38 project.
  • Attempt to use the $t function in a component to access translations.
  • Observe the error mentioned above during compilation or runtime.

System Info

System:
    OS: macOS 14.5
    CPU: (20) arm64 Apple M1 Ultra
    Memory: 24.53 GB / 128.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.nodebrew/node/v18.18.2/bin/node
    Yarn: 1.22.21 - ~/.nodebrew/node/v18.18.2/bin/yarn
    npm: 10.7.0 - ~/.nodebrew/node/v18.18.2/bin/npm
    pnpm: 8.12.1 - ~/.nodebrew/node/v18.18.2/bin/pnpm
  Browsers:
    Chrome: 127.0.6533.120
    Edge: 127.0.2651.105
    Safari: 17.5
  npmPackages:
    @vitejs/plugin-vue: ^5.1.2 => 5.1.2 
    @vue/eslint-config-typescript: ^13.0.0 => 13.0.0 
    vite: ^5.4.2 => 5.4.2 
    vite-plugin-checker: ^0.7.2 => 0.7.2 
    vue: ^3.4.38 => 3.4.38 
    vue-eslint-parser: ^9.4.3 => 9.4.3 
    vue-i18n: ^9.14.0 => 9.14.0 
    vue-router: ^4.4.3 => 4.4.3 
    vue-tsc: ^2.0.29 => 2.0.29

Screenshot

No response

Additional context

No response

Validations

@isamu isamu added the Status: Review Needed Request for review comments label Aug 20, 2024
@kazupon
Copy link
Member

kazupon commented Aug 21, 2024

Thank you for reporting!

This issue duplicate with issue #1919 (comment)

you issue might be caused by your dependencies.
See details,
#1919 (comment)

Thanks!

@kazupon kazupon closed this as completed Aug 21, 2024
@isamu
Copy link
Author

isamu commented Aug 21, 2024

@kazupon

Thank you for your feedback.
I had @vue/runtime-core in my src/shims-vue.d.ts, but changing it to vue fixed the problem.

Thank you for your great software and support.

@davidsandoz
Copy link

I also started getting this issue after updating to vue-i18n v9.14.0, but only in VS Code. The errors with $t are not present when running a type check with the CLI.

From #1919 (comment), I understand that the root cause would be coming from a (sub)dependency that is augmenting @vue/runtime-core instead of vue. In my case, I suppose that this is due to vuejs/language-tools doing that. But I don't see how I can fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed Request for review comments
Projects
None yet
Development

No branches or pull requests

3 participants