global.d.ts 2.3 KB

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