Missing `availableLocales` type in `I18nOptions` interface
hamidyfine opened this issue · comments
Reporting a bug?
When I try to use availableLocales
in the new instance of the VueI18n
get the following error:
// Creating new instance
i18n = new VueI18n({
locale,
availableLocales,
fallbackLocale,
messages,
silentTranslationWarn: true,
...options
});
Typescript error
Object literal may only specify known properties, and 'availableLocales' does not exist in type 'I18nOptions'.
I investigate the error in this file: /node_modules/vue-i18n/types/index.d.ts
and find out that the type of availableLocales
is missing from the I18nOptions
interface.
Expected behavior
The availableLocales
type gets recognized by typescript.
Reproduction
import Vue from 'vue';
import VueI18n from 'vue-i18n';
const i18n = new VueI18n({
locale,
availableLocales,
fallbackLocale,
messages,
silentTranslationWarn: true
});
System Info
System:
OS: Linux 5.13 Zorin OS 16.1
CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
Memory: 868.75 MB / 11.44 GB
Container: Yes
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.15.1 - /usr/bin/node
Yarn: 1.22.18 - /usr/bin/yarn
npm: 8.11.0 - /usr/bin/npm
Browsers:
Chrome: 103.0.5060.53
Firefox: 101.0.1
Screenshot
No response
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.
Thank you for your reproting!
availableLocales
is read-only property on the VueI18n instance.
So, We couldn't pass the construction options of VueI18n
Type definition code is here:
Lines 138 to 160 in ac83e9b
However, docs say availableLocales
can be passed to the constructor option.
That is incorrect documentation
We need to fix it.
Thanks for your feedback!