types.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // copy from element-plus
  2. import type { CSSProperties, Plugin } from 'vue';
  3. type OptionalKeys<T extends Record<string, unknown>> = {
  4. [K in keyof T]: T extends Record<K, T[K]> ? never : K;
  5. }[keyof T];
  6. type RequiredKeys<T extends Record<string, unknown>> = Exclude<keyof T, OptionalKeys<T>>;
  7. type MonoArgEmitter<T, Keys extends keyof T> = <K extends Keys>(evt: K, arg?: T[K]) => void;
  8. type BiArgEmitter<T, Keys extends keyof T> = <K extends Keys>(evt: K, arg: T[K]) => void;
  9. export type EventEmitter<T extends Record<string, unknown>> = MonoArgEmitter<T, OptionalKeys<T>> &
  10. BiArgEmitter<T, RequiredKeys<T>>;
  11. export type AnyFunction<T> = (...args: any[]) => T;
  12. export type PartialReturnType<T extends (...args: unknown[]) => unknown> = Partial<ReturnType<T>>;
  13. export type SFCWithInstall<T> = T & Plugin;
  14. export type Nullable<T> = T | null;
  15. export type RefElement = Nullable<HTMLElement>;
  16. export type CustomizedHTMLElement<T> = HTMLElement & T;
  17. export type Indexable<T> = {
  18. [key: string]: T;
  19. };
  20. export type Hash<T> = Indexable<T>;
  21. export type TimeoutHandle = ReturnType<typeof global.setTimeout>;
  22. export type ComponentSize = 'large' | 'medium' | 'small' | 'mini';
  23. export type StyleValue = string | CSSProperties | Array<StyleValue>;
  24. export type Mutable<T> = { -readonly [P in keyof T]: T[P] };