Ben Lin
2024-06-25 4969a965adc32d3194763edfa4a4f74a7f26cd06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
 * 任意类型的异步函数
 */
type AnyPromiseFunction = (...arg: any[]) => PromiseLike<any>;
 
/**
 * 任意类型的普通函数
 */
type AnyNormalFunction = (...arg: any[]) => any;
 
/**
 * 任意类型的函数
 */
type AnyFunction = AnyNormalFunction | AnyPromiseFunction;
 
/**
 *  T | null 包装
 */
type Nullable<T> = T | null;
 
/**
 * T | Not null 包装
 */
type NonNullable<T> = T extends null | undefined ? never : T;
 
/**
 * 字符串类型对象
 */
type Recordable<T = any> = Record<string, T>;
 
/**
 * 字符串类型对象(只读)
 */
interface ReadonlyRecordable<T = any> {
  readonly [key: string]: T;
}
 
/**
 * setTimeout 返回值类型
 */
type TimeoutHandle = ReturnType<typeof setTimeout>;
 
/**
 * setInterval 返回值类型
 */
type IntervalHandle = ReturnType<typeof setInterval>;
 
export {
  type AnyFunction,
  type AnyNormalFunction,
  type AnyPromiseFunction,
  type IntervalHandle,
  type NonNullable,
  type Nullable,
  type ReadonlyRecordable,
  type Recordable,
  type TimeoutHandle,
};