mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
chore(nuxt): add return type for entry (#24821)
This commit is contained in:
parent
642d4dc9de
commit
3be4a5d406
@ -1,4 +1,5 @@
|
|||||||
import { createApp, createSSRApp, nextTick } from 'vue'
|
import { createApp, createSSRApp, nextTick } from 'vue'
|
||||||
|
import type { App } from 'vue'
|
||||||
|
|
||||||
// These files must be imported first as they have side effects:
|
// These files must be imported first as they have side effects:
|
||||||
// 1. (we set __webpack_public_path via this import, if using webpack builder)
|
// 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
|
// @ts-expect-error virtual file
|
||||||
import { vueAppRootContainer } from '#build/nuxt.config.mjs'
|
import { vueAppRootContainer } from '#build/nuxt.config.mjs'
|
||||||
|
|
||||||
let entry: Function
|
let entry: (ssrContext?: CreateOptions['ssrContext']) => Promise<App<Element>>
|
||||||
|
|
||||||
if (import.meta.server) {
|
if (import.meta.server) {
|
||||||
entry = async function createNuxtAppServer (ssrContext: CreateOptions['ssrContext']) {
|
entry = async function createNuxtAppServer (ssrContext: CreateOptions['ssrContext']) {
|
||||||
@ -46,7 +47,7 @@ if (import.meta.client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
let vueAppPromise: Promise<any>
|
let vueAppPromise: Promise<App<Element>>
|
||||||
|
|
||||||
entry = async function initApp () {
|
entry = async function initApp () {
|
||||||
if (vueAppPromise) { return vueAppPromise }
|
if (vueAppPromise) { return vueAppPromise }
|
||||||
@ -90,7 +91,8 @@ if (import.meta.client) {
|
|||||||
|
|
||||||
vueAppPromise = entry().catch((error: unknown) => {
|
vueAppPromise = entry().catch((error: unknown) => {
|
||||||
console.error('Error while mounting app:', error)
|
console.error('Error while mounting app:', error)
|
||||||
|
throw error
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (ctx?: CreateOptions['ssrContext']) => entry(ctx)
|
export default (ssrContext?: CreateOptions['ssrContext']) => entry(ssrContext)
|
||||||
|
Loading…
Reference in New Issue
Block a user