intlify: { ...; }; }' is not assignable to parameter of type 'NuxtConfig'.

Aperta
#36 6 commenti 4 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
nuxtjs, typescript
Ambito
tooling

Direzione di ricerca

Inizia con i file nuxt.config.ts e package.json forniti, quindi riproduci l'errore TypeScript utilizzando l'installazione documentata di @intlify/nuxt3. Traccia come è tipizzata l'opzione intlify per defineNuxtConfig e rendi la configurazione type-safe; il lavoro è completato quando l'errore ts(2345) segnalato non compare più, mentre il modulo continua a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

When installing as described by the documentation, the follwing typescript error occurs in the nuxt.config.ts file:
intlify: { ...; }; }' is not assignable to parameter of type 'NuxtConfig'.
Object literal may only specify known properties, and 'intlify' does not exist in type 'NuxtConfig'.ts(2345)

Intlify is working despite the error, but it is important to have the types supported. How can this be achieved?

nuxt.config.ts:

import { defineNuxtConfig } from "nuxt3";

export default defineNuxtConfig({
  ...
  buildModules: [
    "@intlify/nuxt3"
  ],
  intlify: {
    vueI18n: {
      // You can setting same `createI18n` options here !
      baseUrl: "https://my.com",
      defaultLocale: "en",
      localeDir: "locales",
      locale: [
        { code: 'de', iso: 'de-DE', file: 'de-DE.json', dir: 'ltr' },
        { code: 'en', iso: 'en-US', file: 'en-US.json', dir: 'ltr' }
      ],
      strategy: "prefix_and_default",
      lazy: true,
      detectBrowserLanguage: {
        alwaysRedirect: false, 
        fallbackLocale: 'en', 
        redirectOn: 'root', 
        useCookie: true, 
        cookieCrossOrigin: false, 
        cookieDomain: null, 
        cookieKey: 'i18n_redirected', 
        cookieSecure: false
      },
      vuex: false
    },
  }
});

export interface IntlifyModuleOptions {
  /**
   * Options specified for `createI18n` in vue-i18n.
   *
   * If you want to specify not only objects but also functions such as messages functions and modifiers for the option, specify the path where the option is defined.
   * The path should be relative to the Nuxt project.
   */
  vueI18n?: I18nOptions | string
  /**
   * Define the directory where your locale messages files will be placed.
   *
   * If you don't specify this option, default value is `locales`
   */
  localeDir?: string
}

package.json:

{
  "private": true,
  "scripts": {
    "dev": "nuxi dev",
    "build": "nuxi build",
    "start": "node .output/server/index.mjs"
  },
  "devDependencies": {
    "@headlessui/vue": "latest",
    "@heroicons/vue": "latest",
    "@tailwindcss/forms": "latest",
    "@types/tailwindcss": "latest",
    "autoprefixer": "^10.4.0",
    "nuxt3": "latest",
    "tailwindcss": "^3.0.7",
    "@intlify/nuxt3": "^0.1.10"
  }
}
Lingua principale
TypeScript
Stelle
202
Fork
18
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di intlify/nuxt3

Tutte le issue di intlify/nuxt3

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.