`No overload matches this call` when using pluralisation
maggie44 opened this issue · comments
Reporting a bug?
I found that $t now allows pluralisation (https://stackoverflow.com/questions/65340370/vue-i18n-this-tc-is-not-a-function). It works, but there is a Typescript error reported. Here is the code:
import { i18n } from 'boot/i18n'
import { computed } from 'vue'
// eslint-disable-next-line @typescript-eslint/unbound-method
const { t } = i18n.global
export default computed(() => [
{
icon: 'settings',
label: t('menu_items.configuration', 2),
path: 'configuration'
}
])
It correctly fetches the string after the |
as expected.
But shows this error:
No overload matches this call.
Overload 1 of 6, '(key: string, locale: string): string', gave the following error.
Argument of type 'number' is not assignable to parameter of type 'string'.
Overload 2 of 6, '(key: string, list: unknown[]): string', gave the following error.
Argument of type 'number' is not assignable to parameter of type 'unknown[]'.
Overload 3 of 6, '(key: string, named: Record<string, unknown>): string', gave the following error.
Argument of type 'number' is not assignable to parameter of type 'Record<string, unknown>'.ts(2769)
Expected behavior
Importing of t
from i18n to not see the provided number to select the key as an error. Is it possible the typings are not updated?
Reproduction
https://github.com/maggie0002/test-i18n
See error in src/components/styles/menuList.ts:
label: t('menu_items.configuration', 2),
Ts errors are not found by lint, so yarn lint
will not reproduce. Instead, make sure the node_modules are installed and view through Visual Studio Code.
System Info
npx: installed 1 in 1.054s
System:
OS: macOS 12.2.1
CPU: (8) arm64 Apple M1
Memory: 156.55 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.19.1 - /opt/homebrew/opt/node@14/bin/node
Yarn: 1.22.18 - ~/.yarn/bin/yarn
npm: 6.14.16 - /opt/homebrew/opt/node@14/bin/npm
Browsers:
Firefox: 91.0.2
Firefox Developer Edition: 99.0
Safari: 15.3
npmPackages:
@intlify/eslint-plugin-vue-i18n: ^1.3.0 => 1.4.0
@intlify/vite-plugin-vue-i18n: ^3.3.1 => 3.3.1
vue: ^3.0.0 => 3.2.31
vue-chart-3: ^3.1.8 => 3.1.8
vue-i18n: ^9.0.0 => 9.1.9
vue-router: ^4.0.0 => 4.0.14
Screenshot
Additional context
No response
Validations
- Read the Contributing Guidelines
- Read the Documentation
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion
- The provided reproduction is a minimal reproducible example of the bug.
Eek, embarrassingly I am on "vue-i18n": "^9.0.0",
and perhaps should have posted this issue on the -next repo? Should I close and reopen?
Thank you for your reporting!
I hope you will close this issue, and you would open a new issue at vue-i18n-next
https://github.com/intlify/vue-i18n-next
Thanks!
Will do, thanks: