We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
watch
locale
When locale is specified as the first argument of watch, the type inference of the watch callback argument cannot be inferred correctly.
When locale is specified as the first argument of watch, the type inference of the watch callback argument should be inferred correctly.
locale type is WritableComputedRef<Locales> https://github.com/intlify/vue-i18n-next/blob/master/packages/vue-i18n-core/src/composer.ts#L1131
WritableComputedRef<Locales>
so, watch callback argument type should be inferred with Locales.
Locales
https://github.com/intlify/vite-vue-i18n-starter/blame/repro-watch/src/App.vue#L26-L31
System: OS: macOS 10.15.7 CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Memory: 390.03 MB / 64.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.17.0 - ~/bin/.nvm/versions/node/v14.17.0/bin/node Yarn: 1.22.10 - ~/bin/.nvm/versions/node/v14.17.0/bin/yarn npm: 6.14.13 - ~/bin/.nvm/versions/node/v14.17.0/bin/npm Browsers: Chrome: 92.0.4515.131 Safari: 14.1.2 npmPackages: vue: ^3.2.1 => 3.2.1 vue-i18n: ^9.2.0-beta.1 => 9.2.0-beta.1
No response
Workaround:
watch((() => locale.value), newlocale => { console.log(typeof newLocale) // output is 'string' })
watch(locale, newLocale => { const n = newLocale as unknown as string })
The text was updated successfully, but these errors were encountered:
@kazupon
This might be a work around:
watch(() => locale.value, newLocale => { console.log(typeof newLocale) })
I just tested, in this case, the type of newLocale is string.
newLocale
Sorry, something went wrong.
@PeterAlfredLee Oh... I forgot it use the function at watch 😅 Thanks!
So, I'll update the new workaround with your suggestion. 😉
No branches or pull requests
Reporting a bug?
When
locale
is specified as the first argument ofwatch
, the type inference of thewatch
callback argument cannot be inferred correctly.Expected behavior
When
locale
is specified as the first argument ofwatch
, the type inference of thewatch
callback argument should be inferred correctly.locale
type isWritableComputedRef<Locales>
https://github.com/intlify/vue-i18n-next/blob/master/packages/vue-i18n-core/src/composer.ts#L1131
so,
watch
callback argument type should be inferred withLocales
.Reproduction
https://github.com/intlify/vite-vue-i18n-starter/blame/repro-watch/src/App.vue#L26-L31
System Info
Screenshot
No response
Additional context
Workaround:
Validations
The text was updated successfully, but these errors were encountered: