Browse Source

perf: 为createAsyncComponent函数增加类型推导 (#2967) (#2991)

pull/3005/head
invalid w 2 years ago
committed by GitHub
parent
commit
a9017da294
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/utils/factory/createAsyncComponent.tsx

9
src/utils/factory/createAsyncComponent.tsx

@ -1,4 +1,7 @@
import {
AsyncComponentLoader,
Component,
ComponentPublicInstance,
defineAsyncComponent,
// FunctionalComponent, CSSProperties
} from 'vue';
@ -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,

Loading…
Cancel
Save