global.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. }
  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_BUILD_COMPRESS_DELETE_ORIGIN_FILE: boolean
  62. VITE_LEGACY: boolean
  63. VITE_USE_IMAGEMIN: boolean
  64. VITE_GENERATE_UI: string
  65. }
  66. declare function parseInt(s: string | number, radix?: number): number
  67. declare function parseFloat(string: string | number): number
  68. namespace JSX {
  69. // tslint:disable no-empty-interface
  70. type Element = VNode
  71. // tslint:disable no-empty-interface
  72. type ElementClass = ComponentRenderProxy
  73. interface ElementAttributesProperty {
  74. $props: any
  75. }
  76. interface IntrinsicElements {
  77. [elem: string]: any
  78. }
  79. interface IntrinsicAttributes {
  80. [elem: string]: any
  81. }
  82. }
  83. }
  84. declare module 'vue' {
  85. export type JSXComponent<Props = any> =
  86. | { new(): ComponentPublicInstance<Props> }
  87. | FunctionalComponent<Props>
  88. }