mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
fix(schema): exclude non-serialisable types from app
options (#27478)
This commit is contained in:
parent
a4f739f077
commit
5785332626
@ -141,12 +141,14 @@ export interface AppConfigInput extends CustomAppConfig {
|
||||
server?: never
|
||||
}
|
||||
|
||||
type Serializable<T> = T extends Function ? never : T extends Promise<infer U> ? Serializable<U> : T extends Record<string, any> ? { [K in keyof T]: Serializable<T[K]> } : T
|
||||
|
||||
export interface NuxtAppConfig {
|
||||
head: AppHeadMetaObject
|
||||
layoutTransition: boolean | TransitionProps
|
||||
pageTransition: boolean | TransitionProps
|
||||
head: Serializable<AppHeadMetaObject>
|
||||
layoutTransition: boolean | Serializable<TransitionProps>
|
||||
pageTransition: boolean | Serializable<TransitionProps>
|
||||
viewTransition?: boolean | 'always'
|
||||
keepalive: boolean | KeepAliveProps
|
||||
keepalive: boolean | Serializable<KeepAliveProps>
|
||||
}
|
||||
|
||||
export interface AppConfig {
|
||||
|
12
test/fixtures/basic-types/nuxt.config.ts
vendored
12
test/fixtures/basic-types/nuxt.config.ts
vendored
@ -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: '',
|
||||
|
1
test/fixtures/basic-types/types.ts
vendored
1
test/fixtures/basic-types/types.ts
vendored
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user