Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

types: locale property from nuxtApp.$i18n is string & computedRef<string> #2157

Open
huang-julien opened this issue Jun 13, 2023 · 1 comment
Assignees
Labels
🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing typescript upstream issue

Comments

@huang-julien
Copy link
Contributor

Environment


  • Operating System: Windows_NT
  • Node Version: v18.15.0
  • Nuxt Version: 3.4.1
  • Nitro Version: 2.3.3
  • Package Manager: pnpm@8.6.0
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

image

Describe the bug

when using useNuxtApp().$i18n.locale, the returned type is string & WritableComputedRef<string> which can be very confusing for developers and even linters as it does not warns that it is an object when migrating from i18n vue 2, Nuxt 2 or bridge.

Additional context

No response

Logs

No response

@kazupon kazupon added v8 upstream issue 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing typescript and removed pending triage labels Jun 14, 2023 — with Volta.net
Copy link
Collaborator

kazupon commented Jun 14, 2023

This issue is related to vue-i18n v9.
vue-i18n v9 has a Legacy API (options API) style and a composition API style.
vue-i18n should support the type inference for both API styles.
ref: intlify/vue-i18n#1113 (comment)

BTW, nuxt i18n module allows you to change the type behavior of $i18n with the types option.
https://v8.i18n.nuxtjs.org/options/misc#types

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing typescript upstream issue
Projects
None yet
Development

No branches or pull requests

3 participants