fix(nuxt): ensure typed layout prop persists through build (#22855)

This commit is contained in:
Maik Kowol 2023-08-27 21:44:43 +02:00 committed by GitHub
parent 424dc8d7c0
commit a256c87406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -81,7 +81,7 @@ export default defineComponent({
}
}
}) as unknown as DefineComponent<{
name?: unknown extends PageMeta['layout'] ? MaybeRef<string | false> : PageMeta['layout']
name?: (unknown extends PageMeta['layout'] ? MaybeRef<string | false> : PageMeta['layout']) | undefined;
}>
const LayoutProvider = defineComponent({

View File

@ -7,7 +7,7 @@ import type { AppConfig, RuntimeValue } from 'nuxt/schema'
import { defineNuxtConfig } from 'nuxt/config'
import { callWithNuxt, isVue3 } from '#app'
import type { NavigateToOptions } from '#app/composables/router'
import { NuxtLink, NuxtPage, WithTypes } from '#components'
import { NuxtLayout, NuxtLink, NuxtPage, WithTypes } from '#components'
import { useRouter } from '#imports'
interface TestResponse { message: string }
@ -207,6 +207,13 @@ describe('layouts', () => {
// @ts-expect-error Invalid layout
definePageMeta({ layout: 'invalid-layout' })
})
it('allows typing layouts', () => {
h(NuxtLayout, { name: 'custom' })
// @ts-expect-error Invalid layout
h(NuxtLayout, { name: 'invalid-layout' })
})
})
describe('modules', () => {