feat(nuxt3): add global type definitions for built-in components (#2340)

This commit is contained in:
Daniel Roe 2021-12-10 13:46:53 +00:00 committed by GitHub
parent 617a65a691
commit fb33033f45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -5,6 +5,11 @@ import { defineNuxtPlugin } from '#app'
// @ts-ignore // @ts-ignore
import metaConfig from '#build/meta.config.mjs' import metaConfig from '#build/meta.config.mjs'
type MetaComponents = typeof Components
declare module 'vue' {
export interface GlobalComponents extends MetaComponents {}
}
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {
useMeta(metaConfig.globalMeta) useMeta(metaConfig.globalMeta)

View File

@ -12,6 +12,15 @@ import { defineNuxtPlugin } from '#app'
// @ts-ignore // @ts-ignore
import routes from '#build/routes' import routes from '#build/routes'
declare module 'vue' {
export interface GlobalComponents {
NuxtChild: typeof NuxtChild
NuxtPage: typeof NuxtPage
NuxtLayout: typeof NuxtLayout
NuxtLink: typeof RouterLink
}
}
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.component('NuxtChild', NuxtChild) nuxtApp.vueApp.component('NuxtChild', NuxtChild)
nuxtApp.vueApp.component('NuxtPage', NuxtPage) nuxtApp.vueApp.component('NuxtPage', NuxtPage)