nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.76k stars 484 forks source link

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

Open huang-julien opened 1 year ago

huang-julien commented 1 year ago

Environment


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 commented 1 year ago

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: https://github.com/intlify/vue-i18n-next/issues/1113#issuecomment-1210711003

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