'Typescript & nuxt : i18n types doesn't work

i am using nuxtjs/i18n in typescript and i've added its types in TS config :

{
  "compilerOptions": {
    "types": [
      "@nuxt/types",
      "@nuxtjs/i18n",
    ]
  }
}

But in componnets when i want to use

this.$i18n.locales

i have this error

enter image description here

enter image description here

so , How can I fix types error for @nuxt/i18n ?



Solution 1:[1]

Try something like this:

import { LocaleObject } from '@nuxtjs/i18n'
...
(this.$i18n.locales as LocaleObject[])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 anotherOneHere