diff --git a/packages/schema/src/types/config.ts b/packages/schema/src/types/config.ts index eaee96bc52..7306c5222e 100644 --- a/packages/schema/src/types/config.ts +++ b/packages/schema/src/types/config.ts @@ -141,12 +141,14 @@ export interface AppConfigInput extends CustomAppConfig { server?: never } +type Serializable = T extends Function ? never : T extends Promise ? Serializable : T extends Record ? { [K in keyof T]: Serializable } : T + export interface NuxtAppConfig { - head: AppHeadMetaObject - layoutTransition: boolean | TransitionProps - pageTransition: boolean | TransitionProps + head: Serializable + layoutTransition: boolean | Serializable + pageTransition: boolean | Serializable viewTransition?: boolean | 'always' - keepalive: boolean | KeepAliveProps + keepalive: boolean | Serializable } export interface AppConfig { diff --git a/test/fixtures/basic-types/nuxt.config.ts b/test/fixtures/basic-types/nuxt.config.ts index 75c3211841..983039bcdf 100644 --- a/test/fixtures/basic-types/nuxt.config.ts +++ b/test/fixtures/basic-types/nuxt.config.ts @@ -15,6 +15,18 @@ export default defineNuxtConfig({ extends: [ './extends/node_modules/foo', ], + app: { + head: { + // @ts-expect-error Promises are not allowed + title: Promise.resolve('Nuxt Fixture'), + // @ts-expect-error Functions are not allowed + titleTemplate: title => 'test', + }, + pageTransition: { + // @ts-expect-error Functions are not allowed + onBeforeEnter: el => console.log(el), + }, + }, runtimeConfig: { baseURL: '', baseAPIToken: '', diff --git a/test/fixtures/basic-types/types.ts b/test/fixtures/basic-types/types.ts index 586fb7c528..dad52b4f6a 100644 --- a/test/fixtures/basic-types/types.ts +++ b/test/fixtures/basic-types/types.ts @@ -320,6 +320,7 @@ describe('runtimeConfig', () => { describe('head', () => { it('correctly types nuxt.config options', () => { + // @ts-expect-error invalid head option defineNuxtConfig({ app: { head: { titleTemplate: () => 'test' } } }) defineNuxtConfig({ app: {