@types/node 22.18.6 → 22.18.8

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.
node v22.18/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v22.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Thu, 18 Sep 2025 00:04:03 GMT
11
+ * Last updated: Tue, 30 Sep 2025 23:32:16 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node v22.18/assert.d.ts CHANGED
@@ -11,6 +11,25 @@ declare module "assert" {
11
11
  */
12
12
  function assert(value: unknown, message?: string | Error): asserts value;
13
13
  namespace assert {
14
+ type AssertMethodNames =
15
+ | "deepEqual"
16
+ | "deepStrictEqual"
17
+ | "doesNotMatch"
18
+ | "doesNotReject"
19
+ | "doesNotThrow"
20
+ | "equal"
21
+ | "fail"
22
+ | "ifError"
23
+ | "match"
24
+ | "notDeepEqual"
25
+ | "notDeepStrictEqual"
26
+ | "notEqual"
27
+ | "notStrictEqual"
28
+ | "ok"
29
+ | "partialDeepStrictEqual"
30
+ | "rejects"
31
+ | "strictEqual"
32
+ | "throws";
14
33
  /**
15
34
  * Indicates the failure of an assertion. All errors thrown by the `node:assert` module will be instances of the `AssertionError` class.
16
35
  */
node v22.18/events.d.ts CHANGED
@@ -36,39 +36,6 @@
36
36
  */
37
37
  declare module "events" {
38
38
  import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
39
- // NOTE: This class is in the docs but is **not actually exported** by Node.
40
- // If https://github.com/nodejs/node/issues/39903 gets resolved and Node
41
- // actually starts exporting the class, uncomment below.
42
- // import { EventListener, EventListenerObject } from '__dom-events';
43
- // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */
44
- // interface NodeEventTarget extends EventTarget {
45
- // /**
46
- // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API.
47
- // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget.
48
- // */
49
- // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
50
- // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */
51
- // eventNames(): string[];
52
- // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */
53
- // listenerCount(type: string): number;
54
- // /** Node.js-specific alias for `eventTarget.removeListener()`. */
55
- // off(type: string, listener: EventListener | EventListenerObject): this;
56
- // /** Node.js-specific alias for `eventTarget.addListener()`. */
57
- // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
58
- // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */
59
- // once(type: string, listener: EventListener | EventListenerObject): this;
60
- // /**
61
- // * Node.js-specific extension to the `EventTarget` class.
62
- // * If `type` is specified, removes all registered listeners for `type`,
63
- // * otherwise removes all registered listeners.
64
- // */
65
- // removeAllListeners(type: string): this;
66
- // /**
67
- // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`.
68
- // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
69
- // */
70
- // removeListener(type: string, listener: EventListener | EventListenerObject): this;
71
- // }
72
39
  interface EventEmitterOptions {
73
40
  /**
74
41
  * Enables automatic capturing of promise rejection.
@@ -584,6 +551,85 @@ declare module "events" {
584
551
  */
585
552
  readonly asyncResource: EventEmitterReferencingAsyncResource;
586
553
  }
554
+ /**
555
+ * The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
556
+ * that emulates a subset of the `EventEmitter` API.
557
+ * @since v14.5.0
558
+ */
559
+ export interface NodeEventTarget extends EventTarget {
560
+ /**
561
+ * Node.js-specific extension to the `EventTarget` class that emulates the
562
+ * equivalent `EventEmitter` API. The only difference between `addListener()` and
563
+ * `addEventListener()` is that `addListener()` will return a reference to the
564
+ * `EventTarget`.
565
+ * @since v14.5.0
566
+ */
567
+ addListener(type: string, listener: (arg: any) => void): this;
568
+ /**
569
+ * Node.js-specific extension to the `EventTarget` class that dispatches the
570
+ * `arg` to the list of handlers for `type`.
571
+ * @since v15.2.0
572
+ * @returns `true` if event listeners registered for the `type` exist,
573
+ * otherwise `false`.
574
+ */
575
+ emit(type: string, arg: any): boolean;
576
+ /**
577
+ * Node.js-specific extension to the `EventTarget` class that returns an array
578
+ * of event `type` names for which event listeners are registered.
579
+ * @since 14.5.0
580
+ */
581
+ eventNames(): string[];
582
+ /**
583
+ * Node.js-specific extension to the `EventTarget` class that returns the number
584
+ * of event listeners registered for the `type`.
585
+ * @since v14.5.0
586
+ */
587
+ listenerCount(type: string): number;
588
+ /**
589
+ * Node.js-specific extension to the `EventTarget` class that sets the number
590
+ * of max event listeners as `n`.
591
+ * @since v14.5.0
592
+ */
593
+ setMaxListeners(n: number): void;
594
+ /**
595
+ * Node.js-specific extension to the `EventTarget` class that returns the number
596
+ * of max event listeners.
597
+ * @since v14.5.0
598
+ */
599
+ getMaxListeners(): number;
600
+ /**
601
+ * Node.js-specific alias for `eventTarget.removeEventListener()`.
602
+ * @since v14.5.0
603
+ */
604
+ off(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
605
+ /**
606
+ * Node.js-specific alias for `eventTarget.addEventListener()`.
607
+ * @since v14.5.0
608
+ */
609
+ on(type: string, listener: (arg: any) => void): this;
610
+ /**
611
+ * Node.js-specific extension to the `EventTarget` class that adds a `once`
612
+ * listener for the given event `type`. This is equivalent to calling `on`
613
+ * with the `once` option set to `true`.
614
+ * @since v14.5.0
615
+ */
616
+ once(type: string, listener: (arg: any) => void): this;
617
+ /**
618
+ * Node.js-specific extension to the `EventTarget` class. If `type` is specified,
619
+ * removes all registered listeners for `type`, otherwise removes all registered
620
+ * listeners.
621
+ * @since v14.5.0
622
+ */
623
+ removeAllListeners(type?: string): this;
624
+ /**
625
+ * Node.js-specific extension to the `EventTarget` class that removes the
626
+ * `listener` for the given `type`. The only difference between `removeListener()`
627
+ * and `removeEventListener()` is that `removeListener()` will return a reference
628
+ * to the `EventTarget`.
629
+ * @since v14.5.0
630
+ */
631
+ removeListener(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
632
+ }
587
633
  }
588
634
  global {
589
635
  namespace NodeJS {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "22.18.6",
3
+ "version": "22.18.8",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -140,6 +140,6 @@
140
140
  "undici-types": "~6.21.0"
141
141
  },
142
142
  "peerDependencies": {},
143
- "typesPublisherContentHash": "223d0ed2825fc2dbdef1d6dd0cb95b10912c9cb13dc3bdb5a089e502d84cbb1b",
143
+ "typesPublisherContentHash": "044f75e3119c1f821a07c434b16c3cebf99c812c67c1db15d8b7abd8caad071d",
144
144
  "typeScriptVersion": "5.2"
145
145
  }
node v22.18/test.d.ts CHANGED
@@ -79,6 +79,7 @@
79
79
  * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/test.js)
80
80
  */
81
81
  declare module "node:test" {
82
+ import { AssertMethodNames } from "node:assert";
82
83
  import { Readable } from "node:stream";
83
84
  import TestFn = test.TestFn;
84
85
  import TestOptions = test.TestOptions;
@@ -1157,29 +1158,7 @@ declare module "node:test" {
1157
1158
  */
1158
1159
  readonly mock: MockTracker;
1159
1160
  }
1160
- interface TestContextAssert extends
1161
- Pick<
1162
- typeof import("assert"),
1163
- | "deepEqual"
1164
- | "deepStrictEqual"
1165
- | "doesNotMatch"
1166
- | "doesNotReject"
1167
- | "doesNotThrow"
1168
- | "equal"
1169
- | "fail"
1170
- | "ifError"
1171
- | "match"
1172
- | "notDeepEqual"
1173
- | "notDeepStrictEqual"
1174
- | "notEqual"
1175
- | "notStrictEqual"
1176
- | "ok"
1177
- | "partialDeepStrictEqual"
1178
- | "rejects"
1179
- | "strictEqual"
1180
- | "throws"
1181
- >
1182
- {
1161
+ interface TestContextAssert extends Pick<typeof import("assert"), AssertMethodNames> {
1183
1162
  /**
1184
1163
  * This function serializes `value` and writes it to the file specified by `path`.
1185
1164
  *
@@ -51,6 +51,7 @@ interface EventListenerObject {
51
51
  handleEvent(object: Event): void;
52
52
  }
53
53
 
54
+ type _EventListenerOptions = typeof globalThis extends { onmessage: any } ? {} : EventListenerOptions;
54
55
  interface EventListenerOptions {
55
56
  capture?: boolean;
56
57
  }
@@ -85,6 +86,8 @@ declare global {
85
86
  new(type: string, eventInitDict?: EventInit): Event;
86
87
  };
87
88
 
89
+ interface EventListenerOptions extends _EventListenerOptions {}
90
+
88
91
  interface EventTarget extends _EventTarget {}
89
92
  var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T
90
93
  : {
@@ -56,7 +56,7 @@
56
56
  */
57
57
  declare module "worker_threads" {
58
58
  import { Context } from "node:vm";
59
- import { EventEmitter } from "node:events";
59
+ import { EventEmitter, NodeEventTarget } from "node:events";
60
60
  import { EventLoopUtilityFunction } from "node:perf_hooks";
61
61
  import { FileHandle } from "node:fs/promises";
62
62
  import { Readable, Writable } from "node:stream";
@@ -111,7 +111,7 @@ declare module "worker_threads" {
111
111
  * This implementation matches [browser `MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) s.
112
112
  * @since v10.5.0
113
113
  */
114
- class MessagePort extends EventEmitter {
114
+ class MessagePort implements EventTarget {
115
115
  /**
116
116
  * Disables further sending of messages on either side of the connection.
117
117
  * This method can be called when no further communication will happen over this `MessagePort`.
@@ -224,42 +224,32 @@ declare module "worker_threads" {
224
224
  * @since v10.5.0
225
225
  */
226
226
  start(): void;
227
- addListener(event: "close", listener: () => void): this;
227
+ addListener(event: "close", listener: (ev: Event) => void): this;
228
228
  addListener(event: "message", listener: (value: any) => void): this;
229
229
  addListener(event: "messageerror", listener: (error: Error) => void): this;
230
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
231
- emit(event: "close"): boolean;
230
+ addListener(event: string, listener: (arg: any) => void): this;
231
+ emit(event: "close", ev: Event): boolean;
232
232
  emit(event: "message", value: any): boolean;
233
233
  emit(event: "messageerror", error: Error): boolean;
234
- emit(event: string | symbol, ...args: any[]): boolean;
235
- 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;
236
240
  on(event: "message", listener: (value: any) => void): this;
237
241
  on(event: "messageerror", listener: (error: Error) => void): this;
238
- on(event: string | symbol, listener: (...args: any[]) => void): this;
239
- once(event: "close", listener: () => void): this;
242
+ on(event: string, listener: (arg: any) => void): this;
243
+ once(event: "close", listener: (ev: Event) => void): this;
240
244
  once(event: "message", listener: (value: any) => void): this;
241
245
  once(event: "messageerror", listener: (error: Error) => void): this;
242
- once(event: string | symbol, listener: (...args: any[]) => void): this;
243
- prependListener(event: "close", listener: () => void): this;
244
- prependListener(event: "message", listener: (value: any) => void): this;
245
- prependListener(event: "messageerror", listener: (error: Error) => void): this;
246
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
247
- prependOnceListener(event: "close", listener: () => void): this;
248
- prependOnceListener(event: "message", listener: (value: any) => void): this;
249
- prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
250
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
251
- removeListener(event: "close", listener: () => void): this;
252
- removeListener(event: "message", listener: (value: any) => void): this;
253
- removeListener(event: "messageerror", listener: (error: Error) => void): this;
254
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
255
- off(event: "close", listener: () => void): this;
256
- off(event: "message", listener: (value: any) => void): this;
257
- off(event: "messageerror", listener: (error: Error) => void): this;
258
- off(event: string | symbol, listener: (...args: any[]) => void): this;
259
- addEventListener: EventTarget["addEventListener"];
260
- dispatchEvent: EventTarget["dispatchEvent"];
261
- 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;
262
251
  }
252
+ interface MessagePort extends NodeEventTarget {}
263
253
  interface WorkerOptions {
264
254
  /**
265
255
  * List of arguments which would be stringified and appended to
@@ -428,24 +418,6 @@ declare module "worker_threads" {
428
418
  * @since v10.5.0
429
419
  */
430
420
  postMessage(value: any, transferList?: readonly Transferable[]): void;
431
- /**
432
- * Sends a value to another worker, identified by its thread ID.
433
- * @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
434
- * If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
435
- * @param value The value to send.
436
- * @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
437
- * or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
438
- * @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
439
- * If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
440
- * @since v22.5.0
441
- */
442
- postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
443
- postMessageToThread(
444
- threadId: number,
445
- value: any,
446
- transferList: readonly Transferable[],
447
- timeout?: number,
448
- ): Promise<void>;
449
421
  /**
450
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
451
423
  * behavior). If the worker is `ref()`ed, calling `ref()` again has