index.d.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // 此文件跟同级目录的 global.d.ts 文件一样也是全局类型声明,只不过这里存放一些零散的全局类型,无需引入直接在 .vue 、.ts 、.tsx 文件使用即可获得类型提示
  2. type RefType<T> = T | null;
  3. type EmitType = (event: string, ...args: any[]) => void;
  4. type TargetContext = "_self" | "_blank";
  5. type ComponentRef<T extends HTMLElement = HTMLDivElement> =
  6. ComponentElRef<T> | null;
  7. type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>;
  8. type ForDataType<T> = {
  9. [P in T]?: ForDataType<T[P]>;
  10. };
  11. type AnyFunction<T> = (...args: any[]) => T;
  12. type PropType<T> = VuePropType<T>;
  13. type Writable<T> = {
  14. -readonly [P in keyof T]: T[P];
  15. };
  16. type Nullable<T> = T | null;
  17. type NonNullable<T> = T extends null | undefined ? never : T;
  18. type Recordable<T = any> = Record<string, T>;
  19. type ReadonlyRecordable<T = any> = {
  20. readonly [key: string]: T;
  21. };
  22. type Indexable<T = any> = {
  23. [key: string]: T;
  24. };
  25. type DeepPartial<T> = {
  26. [P in keyof T]?: DeepPartial<T[P]>;
  27. };
  28. type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
  29. type Exclusive<T, U> = (Without<T, U> & U) | (Without<U, T> & T);
  30. type TimeoutHandle = ReturnType<typeof setTimeout>;
  31. type IntervalHandle = ReturnType<typeof setInterval>;
  32. type Effect = "light" | "dark";
  33. interface ChangeEvent extends Event {
  34. target: HTMLInputElement;
  35. }
  36. interface WheelEvent {
  37. path?: EventTarget[];
  38. }
  39. interface ImportMetaEnv extends ViteEnv {
  40. __: unknown;
  41. }
  42. interface Fn<T = any, R = T> {
  43. (...arg: T[]): R;
  44. }
  45. interface PromiseFn<T = any, R = T> {
  46. (...arg: T[]): Promise<R>;
  47. }
  48. interface ComponentElRef<T extends HTMLElement = HTMLDivElement> {
  49. $el: T;
  50. }
  51. function parseInt(s: string | number, radix?: number): number;
  52. function parseFloat(string: string | number): number;