vue-i18n
vue-i18n copied to clipboard
Types on i18n global instance are too strict
Reporting a bug?
if (!i18n.global.availableLocales.includes(locale)) {
TS2345: Argument of type 'string' is not assignable to parameter of type '"en"'.
Best I can tell, the availableLocales
type is being resolved to an array of exactly the locals that exist when constructed. That's not ideal for
Expected behavior
No type errors.
Reproduction
Follow the lazy loading guide - https://vue-i18n.intlify.dev/guide/advanced/lazy.html#lazy-loading - in a TypeScript file.
System Info
System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Max
Memory: 3.20 GB / 64.00 GB
Shell: 3.5.1 - /opt/homebrew/bin/fish
Binaries:
Node: 18.9.0 - /opt/homebrew/bin/node
npm: 8.19.1 - /opt/homebrew/bin/npm
Browsers:
Chrome: 105.0.5195.102
Firefox: 103.0.2
Safari: 15.6.1
npmPackages:
@intlify/vite-plugin-vue-i18n: 7.0.0-beta.2 => 7.0.0-beta.2
@vitejs/plugin-vue: ^3.1.0 => 3.1.0
@vue/compiler-sfc: ^3.2.39 => 3.2.39
@vue/server-renderer: ^3.2.39 => 3.2.39
@vue/test-utils: ^2.0.2 => 2.0.2
@vue/tsconfig: ^0.1.3 => 0.1.3
vite: ^3.1.0 => 3.1.0
vite-plugin-package-version: ^1.0.2 => 1.0.2
vite-ssr: ^0.16.0 => 0.16.0
vitest: ^0.23.2 => 0.23.2
vue: ^3.2.39 => 3.2.39
vue-eslint-parser: ^9.1.0 => 9.1.0
vue-i18n: 9.3.0-beta.3 => 9.3.0-beta.3
vue-router: ^4.1.5 => 4.1.5
vue-tsc: ^0.40.13 => 0.40.13
### Screenshot
_No response_
### Additional context
_No response_
### Validations
- [X] Read the [Contributing Guidelines](https://github.com/intlify/vue-i18n-next/blob/master/.github/CONTRIBUTING.md)
- [X] Read the [Documentation](https://vue-i18n.intlify.dev/)
- [X] Check that there isn't [already an issue](https://github.com/intlify/vue-i18n-next/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/intlify/vue-i18n-next/discussions)
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.