Skip to content

Commit dfaf9e2

Browse files
kiyuiyyx990803
authored andcommitted
fix(types): type support for advanced async components (#8438)
1 parent 8a2dbf5 commit dfaf9e2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Diff for: types/options.d.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,24 @@ export type Component<Data=DefaultData<never>, Methods=DefaultMethods<never>, Co
1515
interface EsModuleComponent {
1616
default: Component
1717
}
18+
19+
export type AsyncComponent<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps>
20+
= AsyncComponentPromise<Data, Methods, Computed, Props>
21+
| AsyncComponentFactory<Data, Methods, Computed, Props>
1822

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

28+
export type AsyncComponentFactory<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = () => {
29+
component: AsyncComponentPromise<Data, Methods, Computed, Props>;
30+
loading?: Component | EsModuleComponent;
31+
error?: Component | EsModuleComponent;
32+
delay?: number;
33+
timeout?: number;
34+
}
35+
2436
/**
2537
* When the `Computed` type parameter on `ComponentOptions` is inferred,
2638
* it should have a property with the return type of every get-accessor.

0 commit comments

Comments
 (0)