import { Component } from '../runtime/component' ; import { isFunction } from '@vue/shared' ; export type AsyncComponentResolveResult < T = Component > = T | { default : T ; } ; export type AsyncComponentLoader < T = any > = ( ) => Promise < AsyncComponentResolveResult < T > > ; export interface AsyncComponentOptions < T = any > { loader : AsyncComponentLoader < T > ; loadingComponent ? : Component ; errorComponent ? : Component ; delay ? : number ; timeout ? : number ; suspensible ? : boolean ; onError ? ( error , retry , fail , attempts ) : any ; } param options returns export function defineAsyncComponent < T extends Component > ( options ) { let opts = { loader : null , delay : 200 , timeout : null , suspensible : true , } ; if ( isFunction ( options ) ) { opts . loader = options ; } else { Object . assign ( opts , options ) ; } return null as T ; }