chore(nuxt): add return type for entry (#24821)

This commit is contained in:
Daniel Roe 2023-12-19 11:07:43 +01:00 committed by GitHub
parent 642d4dc9de
commit 3be4a5d406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { createApp, createSSRApp, nextTick } from 'vue'
import type { App } from 'vue'
// These files must be imported first as they have side effects:
// 1. (we set __webpack_public_path via this import, if using webpack builder)
@ -17,7 +18,7 @@ import RootComponent from '#build/root-component.mjs'
// @ts-expect-error virtual file
import { vueAppRootContainer } from '#build/nuxt.config.mjs'
let entry: Function
let entry: (ssrContext?: CreateOptions['ssrContext']) => Promise<App<Element>>
if (import.meta.server) {
entry = async function createNuxtAppServer (ssrContext: CreateOptions['ssrContext']) {
@ -46,7 +47,7 @@ if (import.meta.client) {
}
// eslint-disable-next-line
let vueAppPromise: Promise<any>
let vueAppPromise: Promise<App<Element>>
entry = async function initApp () {
if (vueAppPromise) { return vueAppPromise }
@ -90,7 +91,8 @@ if (import.meta.client) {
vueAppPromise = entry().catch((error: unknown) => {
console.error('Error while mounting app:', error)
throw error
})
}
export default (ctx?: CreateOptions['ssrContext']) => entry(ctx)
export default (ssrContext?: CreateOptions['ssrContext']) => entry(ssrContext)