@types/node 22.15.13 → 22.18.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. node v22.18/README.md +15 -0
  2. node/assert.d.ts → node v22.18/assert.d.ts +19 -0
  3. node/buffer.d.ts → node v22.18/buffer.d.ts +6 -2
  4. node/child_process.d.ts → node v22.18/child_process.d.ts +26 -122
  5. node/compatibility/disposable.d.ts → node v22.18/compatibility/disposable.d.ts +0 -2
  6. node/compatibility/indexable.d.ts → node v22.18/compatibility/indexable.d.ts +0 -3
  7. node/compatibility/iterators.d.ts → node v22.18/compatibility/iterators.d.ts +0 -1
  8. node/crypto.d.ts → node v22.18/crypto.d.ts +17 -1
  9. node/diagnostics_channel.d.ts → node v22.18/diagnostics_channel.d.ts +18 -13
  10. node/dns/promises.d.ts → node v22.18/dns/promises.d.ts +36 -9
  11. node/dns.d.ts → node v22.18/dns.d.ts +73 -20
  12. node/events.d.ts → node v22.18/events.d.ts +79 -34
  13. node/fs/promises.d.ts → node v22.18/fs/promises.d.ts +57 -39
  14. node/fs.d.ts → node v22.18/fs.d.ts +98 -47
  15. node v22.18/globals.d.ts +172 -0
  16. node/http.d.ts → node v22.18/http.d.ts +72 -6
  17. node/http2.d.ts → node v22.18/http2.d.ts +81 -2
  18. node/https.d.ts → node v22.18/https.d.ts +5 -0
  19. node/index.d.ts → node v22.18/index.d.ts +7 -3
  20. node/inspector.d.ts → node v22.18/inspector.generated.d.ts +219 -10
  21. node/module.d.ts → node v22.18/module.d.ts +136 -17
  22. node/net.d.ts → node v22.18/net.d.ts +3 -3
  23. node/package.json → node v22.18/package.json +3 -83
  24. node/perf_hooks.d.ts → node v22.18/perf_hooks.d.ts +2 -2
  25. node/process.d.ts → node v22.18/process.d.ts +3 -4
  26. node/readline/promises.d.ts → node v22.18/readline/promises.d.ts +0 -1
  27. node/repl.d.ts → node v22.18/repl.d.ts +3 -5
  28. node/sqlite.d.ts → node v22.18/sqlite.d.ts +207 -0
  29. node/stream/web.d.ts → node v22.18/stream/web.d.ts +8 -0
  30. node/stream.d.ts → node v22.18/stream.d.ts +5 -10
  31. node v22.18/test.d.ts +2162 -0
  32. node/ts5.6/index.d.ts → node v22.18/ts5.6/index.d.ts +7 -3
  33. node/url.d.ts → node v22.18/url.d.ts +12 -3
  34. node/util.d.ts → node v22.18/util.d.ts +20 -5
  35. node/v8.d.ts → node v22.18/v8.d.ts +60 -30
  36. node/vm.d.ts → node v22.18/vm.d.ts +61 -8
  37. node v22.18/web-globals/abortcontroller.d.ts +34 -0
  38. node v22.18/web-globals/domexception.d.ts +68 -0
  39. node v22.18/web-globals/events.d.ts +97 -0
  40. node v22.18/web-globals/fetch.d.ts +46 -0
  41. node v22.18/web-globals/navigator.d.ts +22 -0
  42. node v22.18/web-globals/storage.d.ts +24 -0
  43. node/worker_threads.d.ts → node v22.18/worker_threads.d.ts +105 -74
  44. node/zlib.d.ts → node v22.18/zlib.d.ts +8 -2
  45. node/README.md +0 -15
  46. node/dom-events.d.ts +0 -124
  47. node/globals.d.ts +0 -371
  48. node/test.d.ts +0 -2280
  49. {node → node v22.18}/LICENSE +0 -0
  50. {node → node v22.18}/assert/strict.d.ts +0 -0
  51. node/async_hooks.d.ts → node v22.18/async_hooks.d.ts +1 -1
  52. {node → node v22.18}/buffer.buffer.d.ts +0 -0
  53. {node → node v22.18}/cluster.d.ts +0 -0
  54. {node → node v22.18}/compatibility/index.d.ts +0 -0
  55. {node → node v22.18}/console.d.ts +0 -0
  56. {node → node v22.18}/constants.d.ts +0 -0
  57. {node → node v22.18}/dgram.d.ts +0 -0
  58. {node → node v22.18}/domain.d.ts +0 -0
  59. {node → node v22.18}/globals.typedarray.d.ts +0 -0
  60. {node → node v22.18}/os.d.ts +0 -0
  61. {node → node v22.18}/path.d.ts +0 -0
  62. {node → node v22.18}/punycode.d.ts +0 -0
  63. {node → node v22.18}/querystring.d.ts +0 -0
  64. {node → node v22.18}/readline.d.ts +0 -0
  65. {node → node v22.18}/sea.d.ts +0 -0
  66. {node → node v22.18}/stream/consumers.d.ts +0 -0
  67. {node → node v22.18}/stream/promises.d.ts +0 -0
  68. {node → node v22.18}/string_decoder.d.ts +0 -0
  69. {node → node v22.18}/timers/promises.d.ts +0 -0
  70. {node → node v22.18}/timers.d.ts +0 -0
  71. {node → node v22.18}/tls.d.ts +0 -0
  72. {node → node v22.18}/trace_events.d.ts +0 -0
  73. {node → node v22.18}/ts5.6/buffer.buffer.d.ts +0 -0
  74. {node → node v22.18}/ts5.6/globals.typedarray.d.ts +0 -0
  75. {node → node v22.18}/tty.d.ts +0 -0
  76. {node → node v22.18}/wasi.d.ts +0 -0
@@ -0,0 +1,24 @@
1
+ export {};
2
+
3
+ // These interfaces are absent from lib.webworker, so the conditionals use `onabort` rather than `onmessage`
4
+ type _Storage = typeof globalThis extends { onabort: any } ? {} : Storage;
5
+ interface Storage {
6
+ readonly length: number;
7
+ clear(): void;
8
+ getItem(key: string): string | null;
9
+ key(index: number): string | null;
10
+ removeItem(key: string): void;
11
+ setItem(key: string, value: string): void;
12
+ [key: string]: any;
13
+ }
14
+
15
+ declare global {
16
+ interface Storage extends _Storage {}
17
+ var Storage: typeof globalThis extends { onabort: any; Storage: infer T } ? T : {
18
+ prototype: Storage;
19
+ new(): Storage;
20
+ };
21
+
22
+ var localStorage: Storage;
23
+ var sessionStorage: Storage;
24
+ }
@@ -15,28 +15,31 @@
15
15
  *
16
16
  * ```js
17
17
  * import {
18
- * Worker, isMainThread, parentPort, workerData,
18
+ * Worker,
19
+ * isMainThread,
20
+ * parentPort,
21
+ * workerData,
19
22
  * } from 'node:worker_threads';
20
- * import { parse } from 'some-js-parsing-library';
21
23
  *
22
- * if (isMainThread) {
23
- * module.exports = function parseJSAsync(script) {
24
- * return new Promise((resolve, reject) => {
25
- * const worker = new Worker(__filename, {
26
- * workerData: script,
27
- * });
28
- * worker.on('message', resolve);
29
- * worker.on('error', reject);
30
- * worker.on('exit', (code) => {
31
- * if (code !== 0)
32
- * reject(new Error(`Worker stopped with exit code ${code}`));
33
- * });
34
- * });
35
- * };
36
- * } else {
24
+ * if (!isMainThread) {
25
+ * const { parse } = await import('some-js-parsing-library');
37
26
  * const script = workerData;
38
27
  * parentPort.postMessage(parse(script));
39
28
  * }
29
+ *
30
+ * export default function parseJSAsync(script) {
31
+ * return new Promise((resolve, reject) => {
32
+ * const worker = new Worker(new URL(import.meta.url), {
33
+ * workerData: script,
34
+ * });
35
+ * worker.on('message', resolve);
36
+ * worker.on('error', reject);
37
+ * worker.on('exit', (code) => {
38
+ * if (code !== 0)
39
+ * reject(new Error(`Worker stopped with exit code ${code}`));
40
+ * });
41
+ * });
42
+ * };
40
43
  * ```
41
44
  *
42
45
  * The above example spawns a Worker thread for each `parseJSAsync()` call. In
@@ -52,14 +55,15 @@
52
55
  * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/worker_threads.js)
53
56
  */
54
57
  declare module "worker_threads" {
55
- import { Blob } from "node:buffer";
56
58
  import { Context } from "node:vm";
57
- import { EventEmitter } from "node:events";
59
+ import { EventEmitter, NodeEventTarget } from "node:events";
58
60
  import { EventLoopUtilityFunction } from "node:perf_hooks";
59
61
  import { FileHandle } from "node:fs/promises";
60
62
  import { Readable, Writable } from "node:stream";
63
+ import { ReadableStream, TransformStream, WritableStream } from "node:stream/web";
61
64
  import { URL } from "node:url";
62
- import { X509Certificate } from "node:crypto";
65
+ import { HeapInfo } from "node:v8";
66
+ import { MessageEvent } from "undici-types";
63
67
  const isInternalThread: boolean;
64
68
  const isMainThread: boolean;
65
69
  const parentPort: null | MessagePort;
@@ -89,7 +93,16 @@ declare module "worker_threads" {
89
93
  interface WorkerPerformance {
90
94
  eventLoopUtilization: EventLoopUtilityFunction;
91
95
  }
92
- type TransferListItem = ArrayBuffer | MessagePort | FileHandle | X509Certificate | Blob;
96
+ type Transferable =
97
+ | ArrayBuffer
98
+ | MessagePort
99
+ | AbortSignal
100
+ | FileHandle
101
+ | ReadableStream
102
+ | WritableStream
103
+ | TransformStream;
104
+ /** @deprecated Use `import { Transferable } from "node:worker_threads"` instead. */
105
+ type TransferListItem = Transferable;
93
106
  /**
94
107
  * Instances of the `worker.MessagePort` class represent one end of an
95
108
  * asynchronous, two-way communications channel. It can be used to transfer
@@ -98,7 +111,7 @@ declare module "worker_threads" {
98
111
  * This implementation matches [browser `MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) s.
99
112
  * @since v10.5.0
100
113
  */
101
- class MessagePort extends EventEmitter {
114
+ class MessagePort implements EventTarget {
102
115
  /**
103
116
  * Disables further sending of messages on either side of the connection.
104
117
  * This method can be called when no further communication will happen over this `MessagePort`.
@@ -174,7 +187,12 @@ declare module "worker_threads" {
174
187
  * behind this API, see the `serialization API of the node:v8 module`.
175
188
  * @since v10.5.0
176
189
  */
177
- postMessage(value: any, transferList?: readonly TransferListItem[]): void;
190
+ postMessage(value: any, transferList?: readonly Transferable[]): void;
191
+ /**
192
+ * If true, the `MessagePort` object will keep the Node.js event loop active.
193
+ * @since v18.1.0, v16.17.0
194
+ */
195
+ hasRef(): boolean;
178
196
  /**
179
197
  * Opposite of `unref()`. Calling `ref()` on a previously `unref()`ed port does _not_ let the program exit if it's the only active handle left (the default
180
198
  * behavior). If the port is `ref()`ed, calling `ref()` again has no effect.
@@ -206,42 +224,32 @@ declare module "worker_threads" {
206
224
  * @since v10.5.0
207
225
  */
208
226
  start(): void;
209
- addListener(event: "close", listener: () => void): this;
227
+ addListener(event: "close", listener: (ev: Event) => void): this;
210
228
  addListener(event: "message", listener: (value: any) => void): this;
211
229
  addListener(event: "messageerror", listener: (error: Error) => void): this;
212
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
213
- emit(event: "close"): boolean;
230
+ addListener(event: string, listener: (arg: any) => void): this;
231
+ emit(event: "close", ev: Event): boolean;
214
232
  emit(event: "message", value: any): boolean;
215
233
  emit(event: "messageerror", error: Error): boolean;
216
- emit(event: string | symbol, ...args: any[]): boolean;
217
- on(event: "close", listener: () => void): this;
234
+ emit(event: string, arg: any): boolean;
235
+ off(event: "close", listener: (ev: Event) => void, options?: EventListenerOptions): this;
236
+ off(event: "message", listener: (value: any) => void, options?: EventListenerOptions): this;
237
+ off(event: "messageerror", listener: (error: Error) => void, options?: EventListenerOptions): this;
238
+ off(event: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
239
+ on(event: "close", listener: (ev: Event) => void): this;
218
240
  on(event: "message", listener: (value: any) => void): this;
219
241
  on(event: "messageerror", listener: (error: Error) => void): this;
220
- on(event: string | symbol, listener: (...args: any[]) => void): this;
221
- once(event: "close", listener: () => void): this;
242
+ on(event: string, listener: (arg: any) => void): this;
243
+ once(event: "close", listener: (ev: Event) => void): this;
222
244
  once(event: "message", listener: (value: any) => void): this;
223
245
  once(event: "messageerror", listener: (error: Error) => void): this;
224
- once(event: string | symbol, listener: (...args: any[]) => void): this;
225
- prependListener(event: "close", listener: () => void): this;
226
- prependListener(event: "message", listener: (value: any) => void): this;
227
- prependListener(event: "messageerror", listener: (error: Error) => void): this;
228
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
229
- prependOnceListener(event: "close", listener: () => void): this;
230
- prependOnceListener(event: "message", listener: (value: any) => void): this;
231
- prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
232
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
233
- removeListener(event: "close", listener: () => void): this;
234
- removeListener(event: "message", listener: (value: any) => void): this;
235
- removeListener(event: "messageerror", listener: (error: Error) => void): this;
236
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
237
- off(event: "close", listener: () => void): this;
238
- off(event: "message", listener: (value: any) => void): this;
239
- off(event: "messageerror", listener: (error: Error) => void): this;
240
- off(event: string | symbol, listener: (...args: any[]) => void): this;
241
- addEventListener: EventTarget["addEventListener"];
242
- dispatchEvent: EventTarget["dispatchEvent"];
243
- removeEventListener: EventTarget["removeEventListener"];
246
+ once(event: string, listener: (arg: any) => void): this;
247
+ removeListener(event: "close", listener: (ev: Event) => void, options?: EventListenerOptions): this;
248
+ removeListener(event: "message", listener: (value: any) => void, options?: EventListenerOptions): this;
249
+ removeListener(event: "messageerror", listener: (error: Error) => void, options?: EventListenerOptions): this;
250
+ removeListener(event: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
244
251
  }
252
+ interface MessagePort extends NodeEventTarget {}
245
253
  interface WorkerOptions {
246
254
  /**
247
255
  * List of arguments which would be stringified and appended to
@@ -261,7 +269,7 @@ declare module "worker_threads" {
261
269
  /**
262
270
  * Additional data to send in the first worker message.
263
271
  */
264
- transferList?: TransferListItem[] | undefined;
272
+ transferList?: Transferable[] | undefined;
265
273
  /**
266
274
  * @default true
267
275
  */
@@ -409,25 +417,7 @@ declare module "worker_threads" {
409
417
  * See `port.postMessage()` for more details.
410
418
  * @since v10.5.0
411
419
  */
412
- postMessage(value: any, transferList?: readonly TransferListItem[]): void;
413
- /**
414
- * Sends a value to another worker, identified by its thread ID.
415
- * @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
416
- * If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
417
- * @param value The value to send.
418
- * @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
419
- * or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
420
- * @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
421
- * If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
422
- * @since v22.5.0
423
- */
424
- postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
425
- postMessageToThread(
426
- threadId: number,
427
- value: any,
428
- transferList: readonly TransferListItem[],
429
- timeout?: number,
430
- ): Promise<void>;
420
+ postMessage(value: any, transferList?: readonly Transferable[]): void;
431
421
  /**
432
422
  * Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker does _not_ let the program exit if it's the only active handle left (the default
433
423
  * behavior). If the worker is `ref()`ed, calling `ref()` again has
@@ -457,6 +447,25 @@ declare module "worker_threads" {
457
447
  * @return A promise for a Readable Stream containing a V8 heap snapshot
458
448
  */
459
449
  getHeapSnapshot(): Promise<Readable>;
450
+ /**
451
+ * This method returns a `Promise` that will resolve to an object identical to `v8.getHeapStatistics()`,
452
+ * or reject with an `ERR_WORKER_NOT_RUNNING` error if the worker is no longer running.
453
+ * This methods allows the statistics to be observed from outside the actual thread.
454
+ * @since v22.16.0
455
+ */
456
+ getHeapStatistics(): Promise<HeapInfo>;
457
+ /**
458
+ * Calls `worker.terminate()` when the dispose scope is exited.
459
+ *
460
+ * ```js
461
+ * async function example() {
462
+ * await using worker = new Worker('for (;;) {}', { eval: true });
463
+ * // Worker is automatically terminate when the scope is exited.
464
+ * }
465
+ * ```
466
+ * @since v22.18.0
467
+ */
468
+ [Symbol.asyncDispose](): Promise<void>;
460
469
  addListener(event: "error", listener: (err: Error) => void): this;
461
470
  addListener(event: "exit", listener: (exitCode: number) => void): this;
462
471
  addListener(event: "message", listener: (value: any) => void): this;
@@ -537,18 +546,18 @@ declare module "worker_threads" {
537
546
  * ```
538
547
  * @since v15.4.0
539
548
  */
540
- class BroadcastChannel {
549
+ class BroadcastChannel extends EventTarget {
541
550
  readonly name: string;
542
551
  /**
543
552
  * Invoked with a single \`MessageEvent\` argument when a message is received.
544
553
  * @since v15.4.0
545
554
  */
546
- onmessage: (message: unknown) => void;
555
+ onmessage: (message: MessageEvent) => void;
547
556
  /**
548
557
  * Invoked with a received message cannot be deserialized.
549
558
  * @since v15.4.0
550
559
  */
551
- onmessageerror: (message: unknown) => void;
560
+ onmessageerror: (message: MessageEvent) => void;
552
561
  constructor(name: string);
553
562
  /**
554
563
  * Closes the `BroadcastChannel` connection.
@@ -701,7 +710,25 @@ declare module "worker_threads" {
701
710
  * @param value Any arbitrary, cloneable JavaScript value that will be cloned and passed automatically to all new `Worker` instances. If `value` is passed as `undefined`, any previously set value
702
711
  * for the `key` will be deleted.
703
712
  */
704
- function setEnvironmentData(key: Serializable, value: Serializable): void;
713
+ function setEnvironmentData(key: Serializable, value?: Serializable): void;
714
+ /**
715
+ * Sends a value to another worker, identified by its thread ID.
716
+ * @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
717
+ * If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
718
+ * @param value The value to send.
719
+ * @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
720
+ * or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
721
+ * @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
722
+ * If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
723
+ * @since v22.5.0
724
+ */
725
+ function postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
726
+ function postMessageToThread(
727
+ threadId: number,
728
+ value: any,
729
+ transferList: readonly Transferable[],
730
+ timeout?: number,
731
+ ): Promise<void>;
705
732
 
706
733
  import {
707
734
  BroadcastChannel as _BroadcastChannel,
@@ -709,6 +736,10 @@ declare module "worker_threads" {
709
736
  MessagePort as _MessagePort,
710
737
  } from "worker_threads";
711
738
  global {
739
+ function structuredClone<T>(
740
+ value: T,
741
+ options?: { transfer?: Transferable[] },
742
+ ): T;
712
743
  /**
713
744
  * `BroadcastChannel` class is a global reference for `import { BroadcastChannel } from 'worker_threads'`
714
745
  * https://nodejs.org/api/globals.html#broadcastchannel
@@ -147,6 +147,10 @@ declare module "zlib" {
147
147
  * @default buffer.kMaxLength
148
148
  */
149
149
  maxOutputLength?: number | undefined;
150
+ /**
151
+ * If `true`, returns an object with `buffer` and `engine`.
152
+ */
153
+ info?: boolean | undefined;
150
154
  }
151
155
  interface ZstdOptions {
152
156
  /**
@@ -172,6 +176,10 @@ declare module "zlib" {
172
176
  * @default buffer.kMaxLength
173
177
  */
174
178
  maxOutputLength?: number | undefined;
179
+ /**
180
+ * If `true`, returns an object with `buffer` and `engine`.
181
+ */
182
+ info?: boolean | undefined;
175
183
  }
176
184
  interface Zlib {
177
185
  /** @deprecated Use bytesWritten instead. */
@@ -612,8 +620,6 @@ declare module "zlib" {
612
620
  const Z_FINISH: number;
613
621
  /** @deprecated Use `constants.Z_BLOCK` */
614
622
  const Z_BLOCK: number;
615
- /** @deprecated Use `constants.Z_TREES` */
616
- const Z_TREES: number;
617
623
  // Return codes for the compression/decompression functions.
618
624
  // Negative values are errors, positive values are used for special but normal events.
619
625
  /** @deprecated Use `constants.Z_OK` */
node/README.md DELETED
@@ -1,15 +0,0 @@
1
- # Installation
2
- > `npm install --save @types/node`
3
-
4
- # Summary
5
- This package contains type definitions for node (https://nodejs.org/).
6
-
7
- # Details
8
- Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
-
10
- ### Additional Details
11
- * Last updated: Tue, 06 May 2025 17:02:31 GMT
12
- * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
-
14
- # Credits
15
- These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), [Dmitry Semigradsky](https://github.com/Semigradsky), and [René](https://github.com/Renegade334).
node/dom-events.d.ts DELETED
@@ -1,124 +0,0 @@
1
- export {}; // Don't export anything!
2
-
3
- //// DOM-like Events
4
- // NB: The Event / EventTarget / EventListener implementations below were copied
5
- // from lib.dom.d.ts, then edited to reflect Node's documentation at
6
- // https://nodejs.org/api/events.html#class-eventtarget.
7
- // Please read that link to understand important implementation differences.
8
-
9
- // This conditional type will be the existing global Event in a browser, or
10
- // the copy below in a Node environment.
11
- type __Event = typeof globalThis extends { onmessage: any; Event: any } ? {}
12
- : {
13
- /** This is not used in Node.js and is provided purely for completeness. */
14
- readonly bubbles: boolean;
15
- /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */
16
- cancelBubble: () => void;
17
- /** True if the event was created with the cancelable option */
18
- readonly cancelable: boolean;
19
- /** This is not used in Node.js and is provided purely for completeness. */
20
- readonly composed: boolean;
21
- /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */
22
- composedPath(): [EventTarget?];
23
- /** Alias for event.target. */
24
- readonly currentTarget: EventTarget | null;
25
- /** Is true if cancelable is true and event.preventDefault() has been called. */
26
- readonly defaultPrevented: boolean;
27
- /** This is not used in Node.js and is provided purely for completeness. */
28
- readonly eventPhase: 0 | 2;
29
- /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */
30
- readonly isTrusted: boolean;
31
- /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */
32
- preventDefault(): void;
33
- /** This is not used in Node.js and is provided purely for completeness. */
34
- returnValue: boolean;
35
- /** Alias for event.target. */
36
- readonly srcElement: EventTarget | null;
37
- /** Stops the invocation of event listeners after the current one completes. */
38
- stopImmediatePropagation(): void;
39
- /** This is not used in Node.js and is provided purely for completeness. */
40
- stopPropagation(): void;
41
- /** The `EventTarget` dispatching the event */
42
- readonly target: EventTarget | null;
43
- /** The millisecond timestamp when the Event object was created. */
44
- readonly timeStamp: number;
45
- /** Returns the type of event, e.g. "click", "hashchange", or "submit". */
46
- readonly type: string;
47
- };
48
-
49
- // See comment above explaining conditional type
50
- type __EventTarget = typeof globalThis extends { onmessage: any; EventTarget: any } ? {}
51
- : {
52
- /**
53
- * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value.
54
- *
55
- * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched.
56
- *
57
- * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification.
58
- * Specifically, the `capture` option is used as part of the key when registering a `listener`.
59
- * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`.
60
- */
61
- addEventListener(
62
- type: string,
63
- listener: EventListener | EventListenerObject,
64
- options?: AddEventListenerOptions | boolean,
65
- ): void;
66
- /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */
67
- dispatchEvent(event: Event): boolean;
68
- /** Removes the event listener in target's event listener list with the same type, callback, and options. */
69
- removeEventListener(
70
- type: string,
71
- listener: EventListener | EventListenerObject,
72
- options?: EventListenerOptions | boolean,
73
- ): void;
74
- };
75
-
76
- interface EventInit {
77
- bubbles?: boolean;
78
- cancelable?: boolean;
79
- composed?: boolean;
80
- }
81
-
82
- interface EventListenerOptions {
83
- /** Not directly used by Node.js. Added for API completeness. Default: `false`. */
84
- capture?: boolean;
85
- }
86
-
87
- interface AddEventListenerOptions extends EventListenerOptions {
88
- /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
89
- once?: boolean;
90
- /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
91
- passive?: boolean;
92
- /** The listener will be removed when the given AbortSignal object's `abort()` method is called. */
93
- signal?: AbortSignal;
94
- }
95
-
96
- interface EventListener {
97
- (evt: Event): void;
98
- }
99
-
100
- interface EventListenerObject {
101
- handleEvent(object: Event): void;
102
- }
103
-
104
- import {} from "events"; // Make this an ambient declaration
105
- declare global {
106
- /** An event which takes place in the DOM. */
107
- interface Event extends __Event {}
108
- var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T
109
- : {
110
- prototype: __Event;
111
- new(type: string, eventInitDict?: EventInit): __Event;
112
- };
113
-
114
- /**
115
- * EventTarget is a DOM interface implemented by objects that can
116
- * receive events and may have listeners for them.
117
- */
118
- interface EventTarget extends __EventTarget {}
119
- var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T
120
- : {
121
- prototype: __EventTarget;
122
- new(): __EventTarget;
123
- };
124
- }