mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
fix(nuxt): add missing type for head
in defineNuxtComponent
(#25410)
This commit is contained in:
parent
0152cf48eb
commit
b5981f6840
8
packages/nuxt/src/app/types/augments.d.ts
vendored
8
packages/nuxt/src/app/types/augments.d.ts
vendored
@ -1,3 +1,4 @@
|
||||
import type { UseHeadInput } from "@unhead/vue";
|
||||
import type { NuxtApp, useNuxtApp } from '../nuxt'
|
||||
|
||||
interface NuxtStaticBuildFlags {
|
||||
@ -33,4 +34,11 @@ declare module 'vue' {
|
||||
_nuxtOnBeforeMountCbs: Function[]
|
||||
_nuxtIdIndex?: Record<string, number>
|
||||
}
|
||||
interface ComponentCustomOptions {
|
||||
/**
|
||||
* Available exclusively for `defineNuxtComponent`.
|
||||
* It will not be executed when using `defineComponent`.
|
||||
*/
|
||||
head?(nuxtApp: NuxtApp): UseHeadInput
|
||||
}
|
||||
}
|
||||
|
19
test/fixtures/basic-types/types.ts
vendored
19
test/fixtures/basic-types/types.ts
vendored
@ -329,6 +329,25 @@ describe('head', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
it('types head for defineNuxtComponent', () => {
|
||||
defineNuxtComponent({
|
||||
head(nuxtApp) {
|
||||
expectTypeOf(nuxtApp).not.toBeAny()
|
||||
return {
|
||||
title: 'Site Title'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
defineNuxtComponent({
|
||||
// @ts-expect-error wrong return type for head function
|
||||
head() {
|
||||
return {
|
||||
'test': true
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('components', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user