@types/node 22.18.5 → 22.18.7

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: Tue, 16 Sep 2025 21:32:23 GMT
11
+ * Last updated: Mon, 29 Sep 2025 18:40: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
@@ -584,6 +584,85 @@ declare module "events" {
584
584
  */
585
585
  readonly asyncResource: EventEmitterReferencingAsyncResource;
586
586
  }
587
+ /**
588
+ * The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
589
+ * that emulates a subset of the `EventEmitter` API.
590
+ * @since v14.5.0
591
+ */
592
+ export interface NodeEventTarget extends EventTarget {
593
+ /**
594
+ * Node.js-specific extension to the `EventTarget` class that emulates the
595
+ * equivalent `EventEmitter` API. The only difference between `addListener()` and
596
+ * `addEventListener()` is that `addListener()` will return a reference to the
597
+ * `EventTarget`.
598
+ * @since v14.5.0
599
+ */
600
+ addListener(type: string, listener: (arg: any) => void): this;
601
+ /**
602
+ * Node.js-specific extension to the `EventTarget` class that dispatches the
603
+ * `arg` to the list of handlers for `type`.
604
+ * @since v15.2.0
605
+ * @returns `true` if event listeners registered for the `type` exist,
606
+ * otherwise `false`.
607
+ */
608
+ emit(type: string, arg: any): boolean;
609
+ /**
610
+ * Node.js-specific extension to the `EventTarget` class that returns an array
611
+ * of event `type` names for which event listeners are registered.
612
+ * @since 14.5.0
613
+ */
614
+ eventNames(): string[];
615
+ /**
616
+ * Node.js-specific extension to the `EventTarget` class that returns the number
617
+ * of event listeners registered for the `type`.
618
+ * @since v14.5.0
619
+ */
620
+ listenerCount(type: string): number;
621
+ /**
622
+ * Node.js-specific extension to the `EventTarget` class that sets the number
623
+ * of max event listeners as `n`.
624
+ * @since v14.5.0
625
+ */
626
+ setMaxListeners(n: number): void;
627
+ /**
628
+ * Node.js-specific extension to the `EventTarget` class that returns the number
629
+ * of max event listeners.
630
+ * @since v14.5.0
631
+ */
632
+ getMaxListeners(): number;
633
+ /**
634
+ * Node.js-specific alias for `eventTarget.removeEventListener()`.
635
+ * @since v14.5.0
636
+ */
637
+ off(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
638
+ /**
639
+ * Node.js-specific alias for `eventTarget.addEventListener()`.
640
+ * @since v14.5.0
641
+ */
642
+ on(type: string, listener: (arg: any) => void): this;
643
+ /**
644
+ * Node.js-specific extension to the `EventTarget` class that adds a `once`
645
+ * listener for the given event `type`. This is equivalent to calling `on`
646
+ * with the `once` option set to `true`.
647
+ * @since v14.5.0
648
+ */
649
+ once(type: string, listener: (arg: any) => void): this;
650
+ /**
651
+ * Node.js-specific extension to the `EventTarget` class. If `type` is specified,
652
+ * removes all registered listeners for `type`, otherwise removes all registered
653
+ * listeners.
654
+ * @since v14.5.0
655
+ */
656
+ removeAllListeners(type?: string): this;
657
+ /**
658
+ * Node.js-specific extension to the `EventTarget` class that removes the
659
+ * `listener` for the given `type`. The only difference between `removeListener()`
660
+ * and `removeEventListener()` is that `removeListener()` will return a reference
661
+ * to the `EventTarget`.
662
+ * @since v14.5.0
663
+ */
664
+ removeListener(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
665
+ }
587
666
  }
588
667
  global {
589
668
  namespace NodeJS {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "22.18.5",
3
+ "version": "22.18.7",
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": "c3a028055a82b4b0690a719a5dde08dc62b2425af3276221316d6816564e6b6b",
143
+ "typesPublisherContentHash": "39c99d2d62ee93ed3ecad0b25c74b1a11b51ee4b9dc3931c0e85f96c69c25e04",
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,13 +56,14 @@
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";
63
63
  import { ReadableStream, TransformStream, WritableStream } from "node:stream/web";
64
64
  import { URL } from "node:url";
65
65
  import { HeapInfo } from "node:v8";
66
+ import { MessageEvent } from "undici-types";
66
67
  const isInternalThread: boolean;
67
68
  const isMainThread: boolean;
68
69
  const parentPort: null | MessagePort;
@@ -110,7 +111,7 @@ declare module "worker_threads" {
110
111
  * This implementation matches [browser `MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) s.
111
112
  * @since v10.5.0
112
113
  */
113
- class MessagePort extends EventEmitter {
114
+ class MessagePort extends EventTarget {
114
115
  /**
115
116
  * Disables further sending of messages on either side of the connection.
116
117
  * This method can be called when no further communication will happen over this `MessagePort`.
@@ -223,42 +224,32 @@ declare module "worker_threads" {
223
224
  * @since v10.5.0
224
225
  */
225
226
  start(): void;
226
- addListener(event: "close", listener: () => void): this;
227
+ addListener(event: "close", listener: (ev: Event) => void): this;
227
228
  addListener(event: "message", listener: (value: any) => void): this;
228
229
  addListener(event: "messageerror", listener: (error: Error) => void): this;
229
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
230
- emit(event: "close"): boolean;
230
+ addListener(event: string, listener: (arg: any) => void): this;
231
+ emit(event: "close", ev: Event): boolean;
231
232
  emit(event: "message", value: any): boolean;
232
233
  emit(event: "messageerror", error: Error): boolean;
233
- emit(event: string | symbol, ...args: any[]): boolean;
234
- 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;
235
240
  on(event: "message", listener: (value: any) => void): this;
236
241
  on(event: "messageerror", listener: (error: Error) => void): this;
237
- on(event: string | symbol, listener: (...args: any[]) => void): this;
238
- once(event: "close", listener: () => void): this;
242
+ on(event: string, listener: (arg: any) => void): this;
243
+ once(event: "close", listener: (ev: Event) => void): this;
239
244
  once(event: "message", listener: (value: any) => void): this;
240
245
  once(event: "messageerror", listener: (error: Error) => void): this;
241
- once(event: string | symbol, listener: (...args: any[]) => void): this;
242
- prependListener(event: "close", listener: () => void): this;
243
- prependListener(event: "message", listener: (value: any) => void): this;
244
- prependListener(event: "messageerror", listener: (error: Error) => void): this;
245
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
246
- prependOnceListener(event: "close", listener: () => void): this;
247
- prependOnceListener(event: "message", listener: (value: any) => void): this;
248
- prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
249
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
250
- removeListener(event: "close", listener: () => void): this;
251
- removeListener(event: "message", listener: (value: any) => void): this;
252
- removeListener(event: "messageerror", listener: (error: Error) => void): this;
253
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
254
- off(event: "close", listener: () => void): this;
255
- off(event: "message", listener: (value: any) => void): this;
256
- off(event: "messageerror", listener: (error: Error) => void): this;
257
- off(event: string | symbol, listener: (...args: any[]) => void): this;
258
- addEventListener: EventTarget["addEventListener"];
259
- dispatchEvent: EventTarget["dispatchEvent"];
260
- 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;
261
251
  }
252
+ interface MessagePort extends NodeEventTarget {}
262
253
  interface WorkerOptions {
263
254
  /**
264
255
  * List of arguments which would be stringified and appended to
@@ -427,24 +418,6 @@ declare module "worker_threads" {
427
418
  * @since v10.5.0
428
419
  */
429
420
  postMessage(value: any, transferList?: readonly Transferable[]): void;
430
- /**
431
- * Sends a value to another worker, identified by its thread ID.
432
- * @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
433
- * If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
434
- * @param value The value to send.
435
- * @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
436
- * or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
437
- * @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
438
- * If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
439
- * @since v22.5.0
440
- */
441
- postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
442
- postMessageToThread(
443
- threadId: number,
444
- value: any,
445
- transferList: readonly Transferable[],
446
- timeout?: number,
447
- ): Promise<void>;
448
421
  /**
449
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
450
423
  * behavior). If the worker is `ref()`ed, calling `ref()` again has
@@ -573,18 +546,18 @@ declare module "worker_threads" {
573
546
  * ```
574
547
  * @since v15.4.0
575
548
  */
576
- class BroadcastChannel {
549
+ class BroadcastChannel extends EventTarget {
577
550
  readonly name: string;
578
551
  /**
579
552
  * Invoked with a single \`MessageEvent\` argument when a message is received.
580
553
  * @since v15.4.0
581
554
  */
582
- onmessage: (message: unknown) => void;
555
+ onmessage: (message: MessageEvent) => void;
583
556
  /**
584
557
  * Invoked with a received message cannot be deserialized.
585
558
  * @since v15.4.0
586
559
  */
587
- onmessageerror: (message: unknown) => void;
560
+ onmessageerror: (message: MessageEvent) => void;
588
561
  constructor(name: string);
589
562
  /**
590
563
  * Closes the `BroadcastChannel` connection.