patch.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /// <reference types="node" />
  2. // See https://github.com/nodejs/undici/issues/1740
  3. export type DOMException = typeof globalThis extends { DOMException: infer T }
  4. ? T
  5. : any
  6. export type EventTarget = typeof globalThis extends { EventTarget: infer T }
  7. ? T
  8. : {
  9. addEventListener(
  10. type: string,
  11. listener: any,
  12. options?: any,
  13. ): void
  14. dispatchEvent(event: Event): boolean
  15. removeEventListener(
  16. type: string,
  17. listener: any,
  18. options?: any | boolean,
  19. ): void
  20. }
  21. export type Event = typeof globalThis extends { Event: infer T }
  22. ? T
  23. : {
  24. readonly bubbles: boolean
  25. cancelBubble: () => void
  26. readonly cancelable: boolean
  27. readonly composed: boolean
  28. composedPath(): [EventTarget?]
  29. readonly currentTarget: EventTarget | null
  30. readonly defaultPrevented: boolean
  31. readonly eventPhase: 0 | 2
  32. readonly isTrusted: boolean
  33. preventDefault(): void
  34. returnValue: boolean
  35. readonly srcElement: EventTarget | null
  36. stopImmediatePropagation(): void
  37. stopPropagation(): void
  38. readonly target: EventTarget | null
  39. readonly timeStamp: number
  40. readonly type: string
  41. }
  42. export interface EventInit {
  43. bubbles?: boolean
  44. cancelable?: boolean
  45. composed?: boolean
  46. }
  47. export interface EventListenerOptions {
  48. capture?: boolean
  49. }
  50. export interface AddEventListenerOptions extends EventListenerOptions {
  51. once?: boolean
  52. passive?: boolean
  53. signal?: AbortSignal
  54. }
  55. export type EventListenerOrEventListenerObject = EventListener | EventListenerObject
  56. export interface EventListenerObject {
  57. handleEvent (object: Event): void
  58. }
  59. export interface EventListener {
  60. (evt: Event): void
  61. }