From ecfe5912d05c91d8c3c584840ab108f83bc8131a Mon Sep 17 00:00:00 2001 From: Timur Kiyui Date: Sat, 30 Jun 2018 20:01:57 +0800 Subject: [PATCH 1/2] types: add AsyncComponentFactory type --- types/options.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/types/options.d.ts b/types/options.d.ts index cc58affe6a1..41529e3fe44 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -21,6 +21,14 @@ export type AsyncComponent, Methods=DefaultMethods void ) => Promise | void; +export type AsyncComponentFactory, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = () => { + component: AsyncComponent; + loading?: Component | EsModuleComponent; + error?: Component | EsModuleComponent; + delay?: number; + timeout?: number; +} + /** * When the `Computed` type parameter on `ComponentOptions` is inferred, * it should have a property with the return type of every get-accessor. @@ -86,7 +94,7 @@ export interface ComponentOptions< errorCaptured?(err: Error, vm: Vue, info: string): boolean | void; directives?: { [key: string]: DirectiveFunction | DirectiveOptions }; - components?: { [key: string]: Component | AsyncComponent }; + components?: { [key: string]: Component | AsyncComponent | AsyncComponentFactory }; transitions?: { [key: string]: object }; filters?: { [key: string]: Function }; From 2ac429f073f021e772c799b8ad2d59743876b484 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 5 Dec 2018 17:55:13 -0500 Subject: [PATCH 2/2] Update options.d.ts --- types/options.d.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/types/options.d.ts b/types/options.d.ts index 41529e3fe44..9829569922d 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -15,14 +15,18 @@ export type Component, Methods=DefaultMethods, Co interface EsModuleComponent { default: Component } + +export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> + = AsyncComponentPromise + | AsyncComponentFactory -export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = ( +export type AsyncComponentPromise, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = ( resolve: (component: Component) => void, reject: (reason?: any) => void ) => Promise | void; export type AsyncComponentFactory, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = () => { - component: AsyncComponent; + component: AsyncComponentPromise; loading?: Component | EsModuleComponent; error?: Component | EsModuleComponent; delay?: number; @@ -94,7 +98,7 @@ export interface ComponentOptions< errorCaptured?(err: Error, vm: Vue, info: string): boolean | void; directives?: { [key: string]: DirectiveFunction | DirectiveOptions }; - components?: { [key: string]: Component | AsyncComponent | AsyncComponentFactory }; + components?: { [key: string]: Component | AsyncComponent }; transitions?: { [key: string]: object }; filters?: { [key: string]: Function };