global.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import type {
  2. ComponentRenderProxy,
  3. VNode,
  4. ComponentPublicInstance,
  5. FunctionalComponent,
  6. PropType as VuePropType,
  7. } from 'vue'
  8. declare global {
  9. const __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. mozCancelAnimationFrame: (id?: any) => any,
  22. oCancelAnimationFrame: (id?: any) => any,
  23. msCancelAnimationFrame: (id?: any) => any,
  24. mozRequestAnimationFrame: (id?: any) => any,
  25. oRequestAnimationFrame: (id?: any) => any,
  26. msRequestAnimationFrame: (id?: any) => any
  27. }
  28. // vue
  29. declare type PropType<T> = VuePropType<T>
  30. export type Writable<T> = {
  31. -readonly [P in keyof T]: T[P]
  32. }
  33. declare type Nullable<T> = T | null
  34. declare type NonNullable<T> = T extends null | undefined ? never : T
  35. declare type Recordable<T = any> = Record<string, T>
  36. declare type ReadonlyRecordable<T = any> = {
  37. readonly [key: string]: T
  38. }
  39. declare type Indexable<T = any> = {
  40. [key: string]: T
  41. }
  42. declare type DeepPartial<T> = {
  43. [P in keyof T]?: DeepPartial<T[P]>
  44. }
  45. declare type TimeoutHandle = ReturnType<typeof setTimeout>
  46. declare type IntervalHandle = ReturnType<typeof setInterval>
  47. declare interface ChangeEvent extends Event {
  48. target: HTMLInputElement
  49. }
  50. declare interface WheelEvent {
  51. path?: EventTarget[]
  52. }
  53. interface ImportMetaEnv extends ViteEnv {
  54. __: unknown
  55. }
  56. declare interface ViteEnv {
  57. VITE_PORT: number
  58. VITE_USE_MOCK: boolean
  59. VITE_USE_PWA: boolean
  60. VITE_PUBLIC_PATH: string
  61. VITE_PROXY: [string, string][]
  62. VITE_GLOB_APP_TITLE: string
  63. VITE_GLOB_APP_SHORT_NAME: string
  64. VITE_USE_CDN: boolean
  65. VITE_DROP_CONSOLE: boolean
  66. VITE_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none'
  67. VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE: boolean
  68. VITE_LEGACY: boolean
  69. VITE_USE_IMAGEMIN: boolean
  70. VITE_GENERATE_UI: string
  71. }
  72. declare function parseInt(s: string | number, radix?: number): number
  73. declare function parseFloat(string: string | number): number
  74. namespace JSX {
  75. // tslint:disable no-empty-interface
  76. type Element = VNode
  77. // tslint:disable no-empty-interface
  78. type ElementClass = ComponentRenderProxy
  79. interface ElementAttributesProperty {
  80. $props: any
  81. }
  82. interface IntrinsicElements {
  83. [elem: string]: any
  84. }
  85. interface IntrinsicAttributes {
  86. [elem: string]: any
  87. }
  88. }
  89. }
  90. declare module 'vue' {
  91. export type JSXComponent<Props = any> =
  92. | { new(): ComponentPublicInstance<Props> }
  93. | FunctionalComponent<Props>
  94. }