global.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import type { ComponentRenderProxy, VNode, VNodeChild, ComponentPublicInstance, FunctionalComponent, PropType as VuePropType } from 'vue';
  2. declare global {
  3. const __APP_INFO__: {
  4. pkg: {
  5. name: string;
  6. version: string;
  7. dependencies: Recordable<string>;
  8. devDependencies: Recordable<string>;
  9. };
  10. lastBuildTime: string;
  11. };
  12. // declare interface Window {
  13. // // Global vue app instance
  14. // __APP__: App<Element>;
  15. // }
  16. // vue
  17. declare type PropType<T> = VuePropType<T>;
  18. declare type VueNode = VNodeChild | JSX.Element;
  19. export type Writable<T> = {
  20. -readonly [P in keyof T]: T[P];
  21. };
  22. declare type Nullable<T> = T | null;
  23. declare type NonNullable<T> = T extends null | undefined ? never : T;
  24. declare type Recordable<T = any> = Record<string, T>;
  25. declare type ReadonlyRecordable<T = any> = {
  26. readonly [key: string]: T;
  27. };
  28. declare type Indexable<T = any> = {
  29. [key: string]: T;
  30. };
  31. declare type DeepPartial<T> = {
  32. [P in keyof T]?: DeepPartial<T[P]>;
  33. };
  34. declare type TimeoutHandle = ReturnType<typeof setTimeout>;
  35. declare type IntervalHandle = ReturnType<typeof setInterval>;
  36. declare interface ChangeEvent extends Event {
  37. target: HTMLInputElement;
  38. }
  39. declare interface WheelEvent {
  40. path?: EventTarget[];
  41. }
  42. interface ImportMetaEnv extends ViteEnv {
  43. __: unknown;
  44. }
  45. declare interface ViteEnv {
  46. VITE_PORT: number;
  47. VITE_USE_MOCK: boolean;
  48. VITE_PUBLIC_PATH: string;
  49. VITE_PROXY: [string, string][];
  50. VITE_GLOB_APP_TITLE: string;
  51. VITE_GLOB_APP_SHORT_NAME: string;
  52. VITE_USE_CDN: boolean;
  53. VITE_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none';
  54. VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE: boolean;
  55. }
  56. declare function parseInt(s: string | number, radix?: number): number;
  57. declare function parseFloat(string: string | number): number;
  58. namespace JSX {
  59. // tslint:disable no-empty-interface
  60. type Element = VNode;
  61. // tslint:disable no-empty-interface
  62. type ElementClass = ComponentRenderProxy;
  63. interface ElementAttributesProperty {
  64. $props: any;
  65. }
  66. interface IntrinsicElements {
  67. [elem: string]: any;
  68. }
  69. interface IntrinsicAttributes {
  70. [elem: string]: any;
  71. }
  72. }
  73. }
  74. declare module 'vue' {
  75. export type JSXComponent<Props = any> = { new (): ComponentPublicInstance<Props> } | FunctionalComponent<Props>;
  76. }