nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.65k stars 465 forks source link

Can't match types i18n nuxt.config.ts #2973

Closed fnacarellidev closed 2 weeks ago

fnacarellidev commented 2 weeks ago

Environment


Reproduction

No reproduction required I believe.

Describe the bug

Im not sure if this is actually a bug, but I followed the nuxt i18n documentation and configured my i18n (everything works fine), the problem is, when I run npx nuxi typecheck I get the following error:

error TS2322: Type '{ locales: { code: string; name: string; }[]; defaultLocale: string; vueI18n: string; strategy: string; customRoutes: "config"; pages: { 'tips/index': { en: string; es: string; pt: string; }; 'gallery/index': { ...; }; ... 7 more ...; 'your_disposal_places/index': { ...; }; }; detectBrowserLanguage: { ...; }; }' is not assignable to type 'NuxtI18nOptions'. Type '{ locales: { code: string; name: string; }[]; defaultLocale: string; vueI18n: string; strategy: string; customRoutes: "config"; pages: { 'tips/index': { en: string; es: string; pt: string; }; 'gallery/index': { ...; }; ... 7 more ...; 'your_disposal_places/index': { ...; }; }; detectBrowserLanguage: { ...; }; }' is not assignable to type '{ vueI18n?: string | undefined; experimental?: ExperimentalFeatures | undefined; bundle?: BundleOptions | undefined; compilation?: LocaleMessageCompilationOptions | undefined; ... 16 more ...; parallelPlugin?: boolean | undefined; }'. Types of property 'strategy' are incompatible. Type 'string' is not assignable to type 'Strategies | undefined'.

I took a look into the definitions of NuxtI18nOptions, but it doesn't seem to match the examples given in the documentation, for example:

i18nModules?: { langDir?: string | null; locales?: I18nRoutingOptions['locales']; }[];

there's this field on module.d.ts from nuxtjs/i18n, apparently telling me to use locales inside i18nModules, but when I read this part of the documentation it doesn't specify that. I'm not sure if I'm misinterpreting the documentation.

Additional context

i18n: { locales: [ { code: 'en', name: 'English', }, { code: 'es', name: 'Español', }, { code: 'pt', name: 'Português', }, ], defaultLocale: 'en', vueI18n: './i18n.config.ts', strategy: 'prefix_except_default', customRoutes: 'config', pages: { 'tips/index': { en: '/tips', es: '/consejos', pt: '/dicas', }, 'support/index': { en: '/support', es: '/suporte', pt: '/suporte', }, }, detectBrowserLanguage: { useCookie: true, cookieKey: 'i18n_redirected', redirectOn: 'root', }, },

Logs

No response