victorgarciaesgi / nuxt-typed-router

🚦Provide autocompletion and typecheck to Nuxt router
https://nuxt-typed-router.vercel.app
MIT License
361 stars 12 forks source link

Typing broken with @nuxtjs/i18n #127

Closed ThomasBerne closed 11 months ago

ThomasBerne commented 12 months ago

Describe the bug When adding the @nuxtjs/i18n module in a fresh project, the typing is broken:

image

Expected behavior There should be typing generation in the install of the project and during the development using routing.

Screenshots

image

Environnement infos

Run nuxi infos

- Operating System: Linux
- Node Version:     v20.9.0
- Nuxt Version:     3.8.1
- CLI Version:      3.9.1
- Nitro Version:    2.7.2
- Package Manager:  pnpm@8.10.5
- Builder:          -
- User Config:      modules, i18n, security, tailwindcss, plugins, css, build, vite, devtools
- Runtime Modules:  @nuxt/devtools@1.0.2, nuxt-typed-router@3.3.3, @nuxtjs/i18n@8.0.0-rc.5, nuxt-security@1.0.0-rc.4, nuxt-simple-sitemap@4.1.3, @nuxtjs/robots@3.0.0, @vueuse/nuxt@10.6.1, @nuxtjs/tailwindcss@6.9.5, @pinia/nuxt@0.5.1, @nuxtjs/eslint-module@4.1.0, ()
- Build Modules:    -

Run npx tree-node-cli {your page folder path}

Your nuxt.config.ts Nuxt i18n config :

import type { NuxtI18nOptions } from '@nuxtjs/i18n/dist/module';
import { Locale } from '../../interfaces/locale.interface';

export const i18nConfig: NuxtI18nOptions = {
  vueI18n: './config/i18n/vue-i18n.ts',
  strategy: 'prefix',
  locales: [
    {
      code: Locale.EnUs,
      iso: Locale.EnUs,
      file: './config/i18n/locales/en-US.json',
    },
    {
      code: Locale.Frfr,
      iso: Locale.Frfr,
      file: './config/i18n/locales/fr-FR.json',
    },
  ],
};

And vue-i18n.ts content is:

export default defineI18nConfig(() => ({
  legacy: false,
  locale: 'en',
  numberFormats: {
    'en-US': {
      currency: {
        style: 'currency',
        currency: 'USD',
        notation: 'standard',
      },
    },
    'fr-FR': {
      currency: {
        style: 'currency',
        currency: 'EUR',
        notation: 'standard',
      },
    },
  },
}));
ThomasBerne commented 12 months ago

It looks like it's the vue-i18n.ts file that is breaking the typing. Removing the line : vueI18n: './config/i18n/vue-i18n.ts', in the module options fixes it.

ThomasBerne commented 12 months ago

i found the problem. I forgot this line:

image

victorgarciaesgi commented 11 months ago

Hi! So it's only the defaultLocale that caused the problem? I look at this

victorgarciaesgi commented 11 months ago

Fixed in v3.5.0