@types/node 20.19.16 → 20.19.18

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 v20.19/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/v20.
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 v20.19/assert.d.ts CHANGED
@@ -11,6 +11,24 @@ 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
+ | "rejects"
30
+ | "strictEqual"
31
+ | "throws";
14
32
  /**
15
33
  * Indicates the failure of an assertion. All errors thrown by the `node:assert` module will be instances of the `AssertionError` class.
16
34
  */
node v20.19/events.d.ts CHANGED
@@ -585,6 +585,85 @@ declare module "events" {
585
585
  */
586
586
  readonly asyncResource: EventEmitterReferencingAsyncResource;
587
587
  }
588
+ /**
589
+ * The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
590
+ * that emulates a subset of the `EventEmitter` API.
591
+ * @since v14.5.0
592
+ */
593
+ export interface NodeEventTarget extends EventTarget {
594
+ /**
595
+ * Node.js-specific extension to the `EventTarget` class that emulates the
596
+ * equivalent `EventEmitter` API. The only difference between `addListener()` and
597
+ * `addEventListener()` is that `addListener()` will return a reference to the
598
+ * `EventTarget`.
599
+ * @since v14.5.0
600
+ */
601
+ addListener(type: string, listener: (arg: any) => void): this;
602
+ /**
603
+ * Node.js-specific extension to the `EventTarget` class that dispatches the
604
+ * `arg` to the list of handlers for `type`.
605
+ * @since v15.2.0
606
+ * @returns `true` if event listeners registered for the `type` exist,
607
+ * otherwise `false`.
608
+ */
609
+ emit(type: string, arg: any): boolean;
610
+ /**
611
+ * Node.js-specific extension to the `EventTarget` class that returns an array
612
+ * of event `type` names for which event listeners are registered.
613
+ * @since 14.5.0
614
+ */
615
+ eventNames(): string[];
616
+ /**
617
+ * Node.js-specific extension to the `EventTarget` class that returns the number
618
+ * of event listeners registered for the `type`.
619
+ * @since v14.5.0
620
+ */
621
+ listenerCount(type: string): number;
622
+ /**
623
+ * Node.js-specific extension to the `EventTarget` class that sets the number
624
+ * of max event listeners as `n`.
625
+ * @since v14.5.0
626
+ */
627
+ setMaxListeners(n: number): void;
628
+ /**
629
+ * Node.js-specific extension to the `EventTarget` class that returns the number
630
+ * of max event listeners.
631
+ * @since v14.5.0
632
+ */
633
+ getMaxListeners(): number;
634
+ /**
635
+ * Node.js-specific alias for `eventTarget.removeEventListener()`.
636
+ * @since v14.5.0
637
+ */
638
+ off(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
639
+ /**
640
+ * Node.js-specific alias for `eventTarget.addEventListener()`.
641
+ * @since v14.5.0
642
+ */
643
+ on(type: string, listener: (arg: any) => void): this;
644
+ /**
645
+ * Node.js-specific extension to the `EventTarget` class that adds a `once`
646
+ * listener for the given event `type`. This is equivalent to calling `on`
647
+ * with the `once` option set to `true`.
648
+ * @since v14.5.0
649
+ */
650
+ once(type: string, listener: (arg: any) => void): this;
651
+ /**
652
+ * Node.js-specific extension to the `EventTarget` class. If `type` is specified,
653
+ * removes all registered listeners for `type`, otherwise removes all registered
654
+ * listeners.
655
+ * @since v14.5.0
656
+ */
657
+ removeAllListeners(type?: string): this;
658
+ /**
659
+ * Node.js-specific extension to the `EventTarget` class that removes the
660
+ * `listener` for the given `type`. The only difference between `removeListener()`
661
+ * and `removeEventListener()` is that `removeListener()` will return a reference
662
+ * to the `EventTarget`.
663
+ * @since v14.5.0
664
+ */
665
+ removeListener(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
666
+ }
588
667
  }
589
668
  global {
590
669
  namespace NodeJS {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.19.16",
3
+ "version": "20.19.18",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -135,6 +135,6 @@
135
135
  "undici-types": "~6.21.0"
136
136
  },
137
137
  "peerDependencies": {},
138
- "typesPublisherContentHash": "b8ad83c57c3429d12ae8afeb3490a5a76bb8fe42a17f256e9653dcf4d8c2d54e",
138
+ "typesPublisherContentHash": "cbe08f30d210ae58a5c83c2ad2acbb288537040941f4ef9cbffe58c8611663ab",
139
139
  "typeScriptVersion": "5.2"
140
140
  }
node v20.19/test.d.ts CHANGED
@@ -79,6 +79,7 @@
79
79
  * @see [source](https://github.com/nodejs/node/blob/v20.13.1/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;
@@ -933,28 +934,7 @@ declare module "node:test" {
933
934
  */
934
935
  readonly mock: MockTracker;
935
936
  }
936
- interface TestContextAssert extends
937
- Pick<
938
- typeof import("assert"),
939
- | "deepEqual"
940
- | "deepStrictEqual"
941
- | "doesNotMatch"
942
- | "doesNotReject"
943
- | "doesNotThrow"
944
- | "equal"
945
- | "fail"
946
- | "ifError"
947
- | "match"
948
- | "notDeepEqual"
949
- | "notDeepStrictEqual"
950
- | "notEqual"
951
- | "notStrictEqual"
952
- | "ok"
953
- | "rejects"
954
- | "strictEqual"
955
- | "throws"
956
- >
957
- {}
937
+ interface TestContextAssert extends Pick<typeof import("assert"), AssertMethodNames> {}
958
938
  /**
959
939
  * An instance of `SuiteContext` is passed to each suite function in order to
960
940
  * interact with the test runner. However, the `SuiteContext` constructor is not
@@ -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
  : {
@@ -53,12 +53,13 @@
53
53
  */
54
54
  declare module "worker_threads" {
55
55
  import { Context } from "node:vm";
56
- import { EventEmitter } from "node:events";
56
+ import { EventEmitter, NodeEventTarget } from "node:events";
57
57
  import { EventLoopUtilityFunction } from "node:perf_hooks";
58
58
  import { FileHandle } from "node:fs/promises";
59
59
  import { Readable, Writable } from "node:stream";
60
60
  import { ReadableStream, TransformStream, WritableStream } from "node:stream/web";
61
61
  import { URL } from "node:url";
62
+ import { MessageEvent } from "undici-types";
62
63
  const isMainThread: boolean;
63
64
  const parentPort: null | MessagePort;
64
65
  const resourceLimits: ResourceLimits;
@@ -105,7 +106,7 @@ declare module "worker_threads" {
105
106
  * This implementation matches [browser `MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) s.
106
107
  * @since v10.5.0
107
108
  */
108
- class MessagePort extends EventEmitter {
109
+ class MessagePort extends EventTarget {
109
110
  /**
110
111
  * Disables further sending of messages on either side of the connection.
111
112
  * This method can be called when no further communication will happen over this `MessagePort`.
@@ -213,42 +214,32 @@ declare module "worker_threads" {
213
214
  * @since v10.5.0
214
215
  */
215
216
  start(): void;
216
- addListener(event: "close", listener: () => void): this;
217
+ addListener(event: "close", listener: (ev: Event) => void): this;
217
218
  addListener(event: "message", listener: (value: any) => void): this;
218
219
  addListener(event: "messageerror", listener: (error: Error) => void): this;
219
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
220
- emit(event: "close"): boolean;
220
+ addListener(event: string, listener: (arg: any) => void): this;
221
+ emit(event: "close", ev: Event): boolean;
221
222
  emit(event: "message", value: any): boolean;
222
223
  emit(event: "messageerror", error: Error): boolean;
223
- emit(event: string | symbol, ...args: any[]): boolean;
224
- on(event: "close", listener: () => void): this;
224
+ emit(event: string, arg: any): boolean;
225
+ off(event: "close", listener: (ev: Event) => void, options?: EventListenerOptions): this;
226
+ off(event: "message", listener: (value: any) => void, options?: EventListenerOptions): this;
227
+ off(event: "messageerror", listener: (error: Error) => void, options?: EventListenerOptions): this;
228
+ off(event: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
229
+ on(event: "close", listener: (ev: Event) => void): this;
225
230
  on(event: "message", listener: (value: any) => void): this;
226
231
  on(event: "messageerror", listener: (error: Error) => void): this;
227
- on(event: string | symbol, listener: (...args: any[]) => void): this;
228
- once(event: "close", listener: () => void): this;
232
+ on(event: string, listener: (arg: any) => void): this;
233
+ once(event: "close", listener: (ev: Event) => void): this;
229
234
  once(event: "message", listener: (value: any) => void): this;
230
235
  once(event: "messageerror", listener: (error: Error) => void): this;
231
- once(event: string | symbol, listener: (...args: any[]) => void): this;
232
- prependListener(event: "close", listener: () => void): this;
233
- prependListener(event: "message", listener: (value: any) => void): this;
234
- prependListener(event: "messageerror", listener: (error: Error) => void): this;
235
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
236
- prependOnceListener(event: "close", listener: () => void): this;
237
- prependOnceListener(event: "message", listener: (value: any) => void): this;
238
- prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
239
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
240
- removeListener(event: "close", listener: () => void): this;
241
- removeListener(event: "message", listener: (value: any) => void): this;
242
- removeListener(event: "messageerror", listener: (error: Error) => void): this;
243
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
244
- off(event: "close", listener: () => void): this;
245
- off(event: "message", listener: (value: any) => void): this;
246
- off(event: "messageerror", listener: (error: Error) => void): this;
247
- off(event: string | symbol, listener: (...args: any[]) => void): this;
248
- addEventListener: EventTarget["addEventListener"];
249
- dispatchEvent: EventTarget["dispatchEvent"];
250
- removeEventListener: EventTarget["removeEventListener"];
236
+ once(event: string, listener: (arg: any) => void): this;
237
+ removeListener(event: "close", listener: (ev: Event) => void, options?: EventListenerOptions): this;
238
+ removeListener(event: "message", listener: (value: any) => void, options?: EventListenerOptions): this;
239
+ removeListener(event: "messageerror", listener: (error: Error) => void, options?: EventListenerOptions): this;
240
+ removeListener(event: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
251
241
  }
242
+ interface MessagePort extends NodeEventTarget {}
252
243
  interface WorkerOptions {
253
244
  /**
254
245
  * List of arguments which would be stringified and appended to
@@ -417,24 +408,6 @@ declare module "worker_threads" {
417
408
  * @since v10.5.0
418
409
  */
419
410
  postMessage(value: any, transferList?: readonly Transferable[]): void;
420
- /**
421
- * Sends a value to another worker, identified by its thread ID.
422
- * @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
423
- * If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
424
- * @param value The value to send.
425
- * @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
426
- * or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
427
- * @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
428
- * If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
429
- * @since v20.19.0
430
- */
431
- postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
432
- postMessageToThread(
433
- threadId: number,
434
- value: any,
435
- transferList: readonly Transferable[],
436
- timeout?: number,
437
- ): Promise<void>;
438
411
  /**
439
412
  * 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
440
413
  * behavior). If the worker is `ref()`ed, calling `ref()` again has
@@ -544,18 +517,18 @@ declare module "worker_threads" {
544
517
  * ```
545
518
  * @since v15.4.0
546
519
  */
547
- class BroadcastChannel {
520
+ class BroadcastChannel extends EventTarget {
548
521
  readonly name: string;
549
522
  /**
550
523
  * Invoked with a single \`MessageEvent\` argument when a message is received.
551
524
  * @since v15.4.0
552
525
  */
553
- onmessage: (message: unknown) => void;
526
+ onmessage: (message: MessageEvent) => void;
554
527
  /**
555
528
  * Invoked with a received message cannot be deserialized.
556
529
  * @since v15.4.0
557
530
  */
558
- onmessageerror: (message: unknown) => void;
531
+ onmessageerror: (message: MessageEvent) => void;
559
532
  constructor(name: string);
560
533
  /**
561
534
  * Closes the `BroadcastChannel` connection.