Skip to content

Commit

Permalink
perf: 为createAsyncComponent函数增加类型推导 (#2967) (#2991)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjue666 committed Sep 3, 2023
1 parent 1c1ce4b commit a9017da
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/utils/factory/createAsyncComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {
AsyncComponentLoader,
Component,
ComponentPublicInstance,
defineAsyncComponent,
// FunctionalComponent, CSSProperties
} from 'vue';
Expand Down Expand Up @@ -27,7 +30,11 @@ interface Options {
retry?: boolean;
}

export function createAsyncComponent(loader: Fn, options: Options = {}) {
export function createAsyncComponent<
T extends Component = {
new (): ComponentPublicInstance;
},
>(loader: AsyncComponentLoader<T>, options: Options = {}) {
const { size = 'small', delay = 100, timeout = 30000, loading = false, retry = true } = options;
return defineAsyncComponent({
loader,
Expand Down

0 comments on commit a9017da

Please sign in to comment.