Closed BobbieGoede closed 2 months ago
@BobbieGoede
Hmm, π€
The locale
of the current Compose
is resolved by the type parameter as locale: WritableComputedRef<Locales>
.
To support nuxt-i18n use cases, this could be extended more on the Vue I18n side.
e.g. locale: IsNever<CustomLocales> extends true ? WritableComputedRef<Locales> : WritableComputedRef<CustomLocale>
.
It may be possible to dynamically extend the locale.
@kazupon I have a possible solution here https://github.com/intlify/vue-i18n/pull/1890, I have updated this PR to make use of that solution. Let me know if this works for you locally or if a different approach is preferred.
π Linked issue
2857
β Type of change
π Description
This changes type generation to narrow the
Locale
type to the configuredlocales
, this way functions that accept alocale
parameter (such as our composables) will have proper autocompletion for all configured locales.@kazupon There's still an issue/quirk with the type, I'm don't know how to narrow the
locale
property on theComposer
type in the same way, so currently the following would cause a type error:Maybe you know how to resolve this? I don't think this should be merged while this issue is present π
Also working on this https://github.com/BobbieGoede/i18n/pull/49.
π Checklist