Ben Lin
2024-05-27 62f0e403c98fb76d39b8f1150d2bf2f026423b85
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
// copy from element-plus
 
import type { CSSProperties, Plugin } from 'vue';
 
type OptionalKeys<T extends Record<string, unknown>> = {
  [K in keyof T]: T extends Record<K, T[K]> ? never : K;
}[keyof T];
 
type RequiredKeys<T extends Record<string, unknown>> = Exclude<keyof T, OptionalKeys<T>>;
 
type MonoArgEmitter<T, Keys extends keyof T> = <K extends Keys>(evt: K, arg?: T[K]) => void;
 
type BiArgEmitter<T, Keys extends keyof T> = <K extends Keys>(evt: K, arg: T[K]) => void;
 
export type EventEmitter<T extends Record<string, unknown>> = MonoArgEmitter<T, OptionalKeys<T>> &
  BiArgEmitter<T, RequiredKeys<T>>;
 
export type AnyFunction<T> = (...args: any[]) => T;
 
export type PartialReturnType<T extends (...args: unknown[]) => unknown> = Partial<ReturnType<T>>;
 
export type SFCWithInstall<T> = T & Plugin;
 
export type Nullable<T> = T | null;
 
export type RefElement = Nullable<HTMLElement>;
 
export type CustomizedHTMLElement<T> = HTMLElement & T;
 
export type Indexable<T> = {
  [key: string]: T;
};
 
export type Hash<T> = Indexable<T>;
 
export type TimeoutHandle = ReturnType<typeof global.setTimeout>;
 
export type ComponentSize = 'large' | 'medium' | 'small' | 'mini';
 
export type StyleValue = string | CSSProperties | Array<StyleValue>;
 
export type Mutable<T> = { -readonly [P in keyof T]: T[P] };