global.d.ts 2.4 KB

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