Blame view

src/types/global.d.ts 1.53 KB
1
2
3
4
5
6
declare interface Fn<T = any, R = T> {
  (...arg: T[]): R;
}

declare interface PromiseFn<T = any, R = T> {
  (...arg: T[]): Promise<R>;
陈文彬 authored
7
8
9
10
11
12
13
14
}

declare interface IObj<T = any> {
  [key: string]: T;
  [key: number]: T;
}

declare function parseInt(s: string | number, radix?: number): number;
vben authored
15
陈文彬 authored
16
17
18
19
declare function parseFloat(string: string | number): number;

declare type Nullable<T> = T | null;
vben authored
20
21
declare type NonNullable<T> = T extends null | undefined ? never : T;
陈文彬 authored
22
23
24
25
declare type RefType<T> = T | null;

declare type CustomizedHTMLElement<T> = HTMLElement & T;
vben authored
26
declare type Indexable<T extends any = any> = {
陈文彬 authored
27
28
  [key: string]: T;
};
vben authored
29
vben authored
30
31
declare type Recordable<T extends any = any> = Record<string, T>;
32
declare type Hash<T> = Indexable<T>;
陈文彬 authored
33
34
declare type DeepPartial<T> = {
35
  [P in keyof T]?: DeepPartial<T[P]>;
陈文彬 authored
36
37
};
38
39
40
41
42
43
// type DeepPartial<T> = T extends Function
//   ? T
//   : T extends object
//   ? { [K in keyof T]?: DeepPartial<T[K]> }
//   : T;
vben authored
44
declare type LabelValueOptions = {
陈文彬 authored
45
46
47
48
  label: string;
  value: any;
}[];
49
declare type EmitType = (event: string, ...args: any[]) => void;
陈文彬 authored
50
51
declare type TargetContext = '_self' | '_blank';
vben authored
52
53
54
55

declare type TimeoutHandle = ReturnType<typeof setTimeout>;

declare type IntervalHandle = ReturnType<typeof setInterval>;
vben authored
56
57
58
59
60
61
62
63

declare interface ComponentElRef<T extends HTMLElement = HTMLDivElement> {
  $el: T;
}

declare type ComponentRef<T extends HTMLElement = HTMLDivElement> = ComponentElRef<T> | null;

declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>;
vben authored
64
65

type IsSame<A, B> = A | B extends A & B ? true : false;