Skip to content

Commit

Permalink
fix(types): type support for advanced async components (#8438)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiyui authored and yyx990803 committed Dec 5, 2018
1 parent 8a2dbf5 commit dfaf9e2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion types/options.d.ts
Expand Up @@ -15,12 +15,24 @@ export type Component<Data=DefaultData<never>, Methods=DefaultMethods<never>, Co
interface EsModuleComponent {
default: Component
}

export type AsyncComponent<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps>
= AsyncComponentPromise<Data, Methods, Computed, Props>
| AsyncComponentFactory<Data, Methods, Computed, Props>

export type AsyncComponent<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = (
export type AsyncComponentPromise<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = (
resolve: (component: Component<Data, Methods, Computed, Props>) => void,
reject: (reason?: any) => void
) => Promise<Component | EsModuleComponent> | void;

export type AsyncComponentFactory<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = () => {
component: AsyncComponentPromise<Data, Methods, Computed, Props>;
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.
Expand Down

0 comments on commit dfaf9e2

Please sign in to comment.