global.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. declare interface Fn<T = any, R = T> {
  2. (...arg: T[]): R;
  3. }
  4. declare interface PromiseFn<T = any, R = T> {
  5. (...arg: T[]): Promise<R>;
  6. }
  7. declare interface IObj<T = any> {
  8. [key: string]: T;
  9. [key: number]: T;
  10. }
  11. declare function parseInt(s: string | number, radix?: number): number;
  12. declare function parseFloat(string: string | number): number;
  13. declare type Dictionary<T> = Record<string, T>;
  14. declare type Nullable<T> = T | null;
  15. declare type RefInstanceType<T> = {
  16. $: T;
  17. } | null;
  18. declare type RefType<T> = T | null;
  19. declare type CustomizedHTMLElement<T> = HTMLElement & T;
  20. declare type Indexable<T = any> = {
  21. [key: string]: T;
  22. };
  23. declare type Hash<T> = Indexable<T>;
  24. declare type DeepPartial<T> = {
  25. [P in keyof T]?: DeepPartial<T[P]>;
  26. };
  27. // type DeepPartial<T> = T extends Function
  28. // ? T
  29. // : T extends object
  30. // ? { [K in keyof T]?: DeepPartial<T[K]> }
  31. // : T;
  32. declare type LabelValueOptions = {
  33. label: string;
  34. value: any;
  35. }[];
  36. declare type EmitType = (event: string, ...args: any[]) => void;
  37. declare type TargetContext = '_self' | '_blank';
  38. declare type TimeoutHandle = ReturnType<typeof setTimeout>;
  39. declare type IntervalHandle = ReturnType<typeof setInterval>;
  40. declare interface ComponentElRef<T extends HTMLElement = HTMLDivElement> {
  41. $el: T;
  42. }
  43. declare type ComponentRef<T extends HTMLElement = HTMLDivElement> = ComponentElRef<T> | null;
  44. declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>;