1 | export interface ImportGlobOptions<
|
2 | Eager extends boolean,
|
3 | AsType extends string
|
4 | > {
|
5 | |
6 |
|
7 |
|
8 | as?: AsType
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 | eager?: Eager
|
15 | |
16 |
|
17 |
|
18 | import?: string
|
19 | |
20 |
|
21 |
|
22 | query?: string | Record<string, string | number | boolean>
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 | exhaustive?: boolean
|
29 | }
|
30 |
|
31 | export type GeneralImportGlobOptions = ImportGlobOptions<boolean, string>
|
32 |
|
33 | export interface KnownAsTypeMap {
|
34 | raw: string
|
35 | url: string
|
36 | worker: Worker
|
37 | }
|
38 |
|
39 | export interface ImportGlobFunction {
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | <
|
46 | Eager extends boolean,
|
47 | As extends string,
|
48 | T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
|
49 | >(
|
50 | glob: string | string[],
|
51 | options?: ImportGlobOptions<Eager, As>
|
52 | ): (Eager extends true ? true : false) extends true
|
53 | ? Record<string, T>
|
54 | : Record<string, () => Promise<T>>
|
55 | |
56 |
|
57 |
|
58 |
|
59 |
|
60 | <M>(
|
61 | glob: string | string[],
|
62 | options?: ImportGlobOptions<false, string>
|
63 | ): Record<string, () => Promise<M>>
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 | <M>(
|
70 | glob: string | string[],
|
71 | options: ImportGlobOptions<true, string>
|
72 | ): Record<string, M>
|
73 | }
|
74 |
|
75 | export interface ImportGlobEagerFunction {
|
76 | |
77 |
|
78 |
|
79 |
|
80 |
|
81 | <
|
82 | As extends string,
|
83 | T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
|
84 | >(
|
85 | glob: string | string[],
|
86 | options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>
|
87 | ): Record<string, T>
|
88 | |
89 |
|
90 |
|
91 |
|
92 |
|
93 | <M>(
|
94 | glob: string | string[],
|
95 | options?: Omit<ImportGlobOptions<boolean, string>, 'eager'>
|
96 | ): Record<string, M>
|
97 | }
|