mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +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
|
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 {
|
export interface NuxtAppConfig {
|
||||||
head: AppHeadMetaObject
|
head: Serializable<AppHeadMetaObject>
|
||||||
layoutTransition: boolean | TransitionProps
|
layoutTransition: boolean | Serializable<TransitionProps>
|
||||||
pageTransition: boolean | TransitionProps
|
pageTransition: boolean | Serializable<TransitionProps>
|
||||||
viewTransition?: boolean | 'always'
|
viewTransition?: boolean | 'always'
|
||||||
keepalive: boolean | KeepAliveProps
|
keepalive: boolean | Serializable<KeepAliveProps>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppConfig {
|
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: [
|
||||||
'./extends/node_modules/foo',
|
'./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: {
|
runtimeConfig: {
|
||||||
baseURL: '',
|
baseURL: '',
|
||||||
baseAPIToken: '',
|
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', () => {
|
describe('head', () => {
|
||||||
it('correctly types nuxt.config options', () => {
|
it('correctly types nuxt.config options', () => {
|
||||||
|
// @ts-expect-error invalid head option
|
||||||
defineNuxtConfig({ app: { head: { titleTemplate: () => 'test' } } })
|
defineNuxtConfig({ app: { head: { titleTemplate: () => 'test' } } })
|
||||||
defineNuxtConfig({
|
defineNuxtConfig({
|
||||||
app: {
|
app: {
|
||||||
|
Loading…
Reference in New Issue
Block a user