Open drm-addoptio opened 2 years ago
Should be nice if it is in the package, For now you can create a declerations file.
import { IntlifyModuleOptions } from "nuxt3";
declare module "@nuxt/schema" {
export interface NuxtConfig {
intlify?: IntlifyModuleOptions;
}
}
Thank you for this hint. I've put it in the global.d.ts file and now the type error in nuxt.config disappeared.
Now, another type issue arises with this part of the nuxt.config:
export interface IntlifyModuleOptions {
vueI18n?: I18nOptions | string
localeDir?: string
}
I18nOptions is not defined anywhere. Where do I get this from? Or better how to solve this issue?
import { IntlifyModuleOptions } from '@intlify/nuxt3';
declare module '@nuxt/schema' {
export interface NuxtConfig {
intlify?: IntlifyModuleOptions;
}
}
@iamanewofkotlin thank you for clarifying this. So the Import has to be from "@intlify/nuxt3" and no export ... neccessary in nuxt.config itself. Seems to work now.
For anyone else coming across this or similar issues. I learned that Nuxt comes shipped with a nuxt prepare
command.
This command generates types based on the Nuxt configuration. These added definitions should fix issues like this.
When creating a new Nuxt project a postinstall
script will be added to package.json
that should run this command after every install. (npm i
)
You can also run the command manually.
See here for more details. https://nuxt.com/docs/api/commands/prepare
For nuxt 3.4, install typescript as dev dependency can resolve this issue.
https://stackoverflow.com/a/75993774/19420247
npm install typescript --save-dev
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:
package.json: