@types/node 22.5.1 → 22.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "22.5.1",
3
+ "version": "22.5.3",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -212,6 +212,6 @@
212
212
  "dependencies": {
213
213
  "undici-types": "~6.19.2"
214
214
  },
215
- "typesPublisherContentHash": "68531658f8f892c98d6270ea1f2b8332049dafee094c65b9332cf6c1a860d36b",
215
+ "typesPublisherContentHash": "b838738b923117466b69f5c6125cb6df5c4b74969e34cc7a05ba64931ea00574",
216
216
  "typeScriptVersion": "4.8"
217
217
  }
node/stream/web.d.ts CHANGED
@@ -1,3 +1,38 @@
1
+ type _ByteLengthQueuingStrategy = typeof globalThis extends { onmessage: any } ? {}
2
+ : import("stream/web").ByteLengthQueuingStrategy;
3
+ type _CompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {}
4
+ : import("stream/web").CompressionStream;
5
+ type _CountQueuingStrategy = typeof globalThis extends { onmessage: any } ? {}
6
+ : import("stream/web").CountQueuingStrategy;
7
+ type _DecompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {}
8
+ : import("stream/web").DecompressionStream;
9
+ type _ReadableByteStreamController = typeof globalThis extends { onmessage: any } ? {}
10
+ : import("stream/web").ReadableByteStreamController;
11
+ type _ReadableStream<R = any> = typeof globalThis extends { onmessage: any } ? {}
12
+ : import("stream/web").ReadableStream<R>;
13
+ type _ReadableStreamBYOBReader = typeof globalThis extends { onmessage: any } ? {}
14
+ : import("stream/web").ReadableStreamBYOBReader;
15
+ type _ReadableStreamBYOBRequest = typeof globalThis extends { onmessage: any } ? {}
16
+ : import("stream/web").ReadableStreamBYOBRequest;
17
+ type _ReadableStreamDefaultController<R = any> = typeof globalThis extends { onmessage: any } ? {}
18
+ : import("stream/web").ReadableStreamDefaultController<R>;
19
+ type _ReadableStreamDefaultReader<R = any> = typeof globalThis extends { onmessage: any } ? {}
20
+ : import("stream/web").ReadableStreamDefaultReader<R>;
21
+ type _TextDecoderStream = typeof globalThis extends { onmessage: any } ? {}
22
+ : import("stream/web").TextDecoderStream;
23
+ type _TextEncoderStream = typeof globalThis extends { onmessage: any } ? {}
24
+ : import("stream/web").TextEncoderStream;
25
+ type _TransformStream<I = any, O = any> = typeof globalThis extends { onmessage: any } ? {}
26
+ : import("stream/web").TransformStream<I, O>;
27
+ type _TransformStreamDefaultController<O = any> = typeof globalThis extends { onmessage: any } ? {}
28
+ : import("stream/web").TransformStreamDefaultController<O>;
29
+ type _WritableStream<W = any> = typeof globalThis extends { onmessage: any } ? {}
30
+ : import("stream/web").WritableStream<W>;
31
+ type _WritableStreamDefaultController = typeof globalThis extends { onmessage: any } ? {}
32
+ : import("stream/web").WritableStreamDefaultController;
33
+ type _WritableStreamDefaultWriter<W = any> = typeof globalThis extends { onmessage: any } ? {}
34
+ : import("stream/web").WritableStreamDefaultWriter<W>;
35
+
1
36
  declare module "stream/web" {
2
37
  // stub module, pending copy&paste from .d.ts or manual impl
3
38
  // copy from lib.dom.d.ts
@@ -65,18 +100,7 @@ declare module "stream/web" {
65
100
  readonly closed: Promise<undefined>;
66
101
  cancel(reason?: any): Promise<void>;
67
102
  }
68
- interface ReadableStreamDefaultReadValueResult<T> {
69
- done: false;
70
- value: T;
71
- }
72
- interface ReadableStreamDefaultReadDoneResult {
73
- done: true;
74
- value?: undefined;
75
- }
76
103
  type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
77
- type ReadableStreamDefaultReadResult<T> =
78
- | ReadableStreamDefaultReadValueResult<T>
79
- | ReadableStreamDefaultReadDoneResult;
80
104
  interface ReadableStreamReadValueResult<T> {
81
105
  done: false;
82
106
  value: T;
@@ -146,8 +170,9 @@ declare module "stream/web" {
146
170
  interface ReadableStream<R = any> {
147
171
  readonly locked: boolean;
148
172
  cancel(reason?: any): Promise<void>;
149
- getReader(): ReadableStreamDefaultReader<R>;
150
173
  getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
174
+ getReader(): ReadableStreamDefaultReader<R>;
175
+ getReader(options?: ReadableStreamGetReaderOptions): ReadableStreamReader<R>;
151
176
  pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
152
177
  pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
153
178
  tee(): [ReadableStream<R>, ReadableStream<R>];
@@ -160,20 +185,48 @@ declare module "stream/web" {
160
185
  new(underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
161
186
  new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
162
187
  };
188
+ type ReadableStreamReaderMode = "byob";
189
+ interface ReadableStreamGetReaderOptions {
190
+ /**
191
+ * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
192
+ *
193
+ * This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
194
+ */
195
+ mode?: ReadableStreamReaderMode;
196
+ }
197
+ type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBYOBReader;
163
198
  interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
164
- read(): Promise<ReadableStreamDefaultReadResult<R>>;
199
+ read(): Promise<ReadableStreamReadResult<R>>;
165
200
  releaseLock(): void;
166
201
  }
202
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
167
203
  interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
204
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
168
205
  read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
206
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
169
207
  releaseLock(): void;
170
208
  }
171
209
  const ReadableStreamDefaultReader: {
172
210
  prototype: ReadableStreamDefaultReader;
173
211
  new<R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
174
212
  };
175
- const ReadableStreamBYOBReader: any;
176
- const ReadableStreamBYOBRequest: any;
213
+ const ReadableStreamBYOBReader: {
214
+ prototype: ReadableStreamBYOBReader;
215
+ new(stream: ReadableStream): ReadableStreamBYOBReader;
216
+ };
217
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */
218
+ interface ReadableStreamBYOBRequest {
219
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */
220
+ readonly view: ArrayBufferView | null;
221
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */
222
+ respond(bytesWritten: number): void;
223
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */
224
+ respondWithNewView(view: ArrayBufferView): void;
225
+ }
226
+ const ReadableStreamBYOBRequest: {
227
+ prototype: ReadableStreamBYOBRequest;
228
+ new(): ReadableStreamBYOBRequest;
229
+ };
177
230
  interface ReadableByteStreamController {
178
231
  readonly byobRequest: undefined;
179
232
  readonly desiredSize: number | null;
@@ -345,22 +398,208 @@ declare module "stream/web" {
345
398
  prototype: TextDecoderStream;
346
399
  new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream;
347
400
  };
348
- interface CompressionStream<R = any, W = any> {
349
- readonly readable: ReadableStream<R>;
350
- readonly writable: WritableStream<W>;
401
+ interface CompressionStream {
402
+ readonly readable: ReadableStream;
403
+ readonly writable: WritableStream;
351
404
  }
352
405
  const CompressionStream: {
353
406
  prototype: CompressionStream;
354
- new<R = any, W = any>(format: "deflate" | "deflate-raw" | "gzip"): CompressionStream<R, W>;
407
+ new(format: "deflate" | "deflate-raw" | "gzip"): CompressionStream;
355
408
  };
356
- interface DecompressionStream<R = any, W = any> {
357
- readonly readable: ReadableStream<R>;
358
- readonly writable: WritableStream<W>;
409
+ interface DecompressionStream {
410
+ readonly writable: WritableStream;
411
+ readonly readable: ReadableStream;
359
412
  }
360
413
  const DecompressionStream: {
361
414
  prototype: DecompressionStream;
362
- new<R = any, W = any>(format: "deflate" | "deflate-raw" | "gzip"): DecompressionStream<R, W>;
415
+ new(format: "deflate" | "deflate-raw" | "gzip"): DecompressionStream;
363
416
  };
417
+
418
+ global {
419
+ interface ByteLengthQueuingStrategy extends _ByteLengthQueuingStrategy {}
420
+ /**
421
+ * `ByteLengthQueuingStrategy` class is a global reference for `require('stream/web').ByteLengthQueuingStrategy`.
422
+ * https://nodejs.org/api/globals.html#class-bytelengthqueuingstrategy
423
+ * @since v18.0.0
424
+ */
425
+ var ByteLengthQueuingStrategy: typeof globalThis extends { onmessage: any; ByteLengthQueuingStrategy: infer T }
426
+ ? T
427
+ : typeof import("stream/web").ByteLengthQueuingStrategy;
428
+
429
+ interface CompressionStream extends _CompressionStream {}
430
+ /**
431
+ * `CompressionStream` class is a global reference for `require('stream/web').CompressionStream`.
432
+ * https://nodejs.org/api/globals.html#class-compressionstream
433
+ * @since v18.0.0
434
+ */
435
+ var CompressionStream: typeof globalThis extends {
436
+ onmessage: any;
437
+ // CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
438
+ // If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
439
+ ReportingObserver: any;
440
+ CompressionStream: infer T;
441
+ } ? T
442
+ // TS 4.8, 4.9, 5.0
443
+ : typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
444
+ prototype: T;
445
+ new(format: "deflate" | "deflate-raw" | "gzip"): T;
446
+ }
447
+ : typeof import("stream/web").CompressionStream;
448
+
449
+ interface CountQueuingStrategy extends _CountQueuingStrategy {}
450
+ /**
451
+ * `CountQueuingStrategy` class is a global reference for `require('stream/web').CountQueuingStrategy`.
452
+ * https://nodejs.org/api/globals.html#class-countqueuingstrategy
453
+ * @since v18.0.0
454
+ */
455
+ var CountQueuingStrategy: typeof globalThis extends { onmessage: any; CountQueuingStrategy: infer T } ? T
456
+ : typeof import("stream/web").CountQueuingStrategy;
457
+
458
+ interface DecompressionStream extends _DecompressionStream {}
459
+ /**
460
+ * `DecompressionStream` class is a global reference for `require('stream/web').DecompressionStream`.
461
+ * https://nodejs.org/api/globals.html#class-decompressionstream
462
+ * @since v18.0.0
463
+ */
464
+ var DecompressionStream: typeof globalThis extends {
465
+ onmessage: any;
466
+ // CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
467
+ // If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
468
+ ReportingObserver: any;
469
+ DecompressionStream: infer T extends object;
470
+ } ? T
471
+ // TS 4.8, 4.9, 5.0
472
+ : typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
473
+ prototype: T;
474
+ new(format: "deflate" | "deflate-raw" | "gzip"): T;
475
+ }
476
+ : typeof import("stream/web").DecompressionStream;
477
+
478
+ interface ReadableByteStreamController extends _ReadableByteStreamController {}
479
+ /**
480
+ * `ReadableByteStreamController` class is a global reference for `require('stream/web').ReadableByteStreamController`.
481
+ * https://nodejs.org/api/globals.html#class-readablebytestreamcontroller
482
+ * @since v18.0.0
483
+ */
484
+ var ReadableByteStreamController: typeof globalThis extends
485
+ { onmessage: any; ReadableByteStreamController: infer T } ? T
486
+ : typeof import("stream/web").ReadableByteStreamController;
487
+
488
+ interface ReadableStream<R = any> extends _ReadableStream<R> {}
489
+ /**
490
+ * `ReadableStream` class is a global reference for `require('stream/web').ReadableStream`.
491
+ * https://nodejs.org/api/globals.html#class-readablestream
492
+ * @since v18.0.0
493
+ */
494
+ var ReadableStream: typeof globalThis extends { onmessage: any; ReadableStream: infer T } ? T
495
+ : typeof import("stream/web").ReadableStream;
496
+
497
+ interface ReadableStreamBYOBReader extends _ReadableStreamBYOBReader {}
498
+ /**
499
+ * `ReadableStreamBYOBReader` class is a global reference for `require('stream/web').ReadableStreamBYOBReader`.
500
+ * https://nodejs.org/api/globals.html#class-readablestreambyobreader
501
+ * @since v18.0.0
502
+ */
503
+ var ReadableStreamBYOBReader: typeof globalThis extends { onmessage: any; ReadableStreamBYOBReader: infer T }
504
+ ? T
505
+ : typeof import("stream/web").ReadableStreamBYOBReader;
506
+
507
+ interface ReadableStreamBYOBRequest extends _ReadableStreamBYOBRequest {}
508
+ /**
509
+ * `ReadableStreamBYOBRequest` class is a global reference for `require('stream/web').ReadableStreamBYOBRequest`.
510
+ * https://nodejs.org/api/globals.html#class-readablestreambyobrequest
511
+ * @since v18.0.0
512
+ */
513
+ var ReadableStreamBYOBRequest: typeof globalThis extends { onmessage: any; ReadableStreamBYOBRequest: infer T }
514
+ ? T
515
+ : typeof import("stream/web").ReadableStreamBYOBRequest;
516
+
517
+ interface ReadableStreamDefaultController<R = any> extends _ReadableStreamDefaultController<R> {}
518
+ /**
519
+ * `ReadableStreamDefaultController` class is a global reference for `require('stream/web').ReadableStreamDefaultController`.
520
+ * https://nodejs.org/api/globals.html#class-readablestreamdefaultcontroller
521
+ * @since v18.0.0
522
+ */
523
+ var ReadableStreamDefaultController: typeof globalThis extends
524
+ { onmessage: any; ReadableStreamDefaultController: infer T } ? T
525
+ : typeof import("stream/web").ReadableStreamDefaultController;
526
+
527
+ interface ReadableStreamDefaultReader<R = any> extends _ReadableStreamDefaultReader<R> {}
528
+ /**
529
+ * `ReadableStreamDefaultReader` class is a global reference for `require('stream/web').ReadableStreamDefaultReader`.
530
+ * https://nodejs.org/api/globals.html#class-readablestreamdefaultreader
531
+ * @since v18.0.0
532
+ */
533
+ var ReadableStreamDefaultReader: typeof globalThis extends
534
+ { onmessage: any; ReadableStreamDefaultReader: infer T } ? T
535
+ : typeof import("stream/web").ReadableStreamDefaultReader;
536
+
537
+ interface TextDecoderStream extends _TextDecoderStream {}
538
+ /**
539
+ * `TextDecoderStream` class is a global reference for `require('stream/web').TextDecoderStream`.
540
+ * https://nodejs.org/api/globals.html#class-textdecoderstream
541
+ * @since v18.0.0
542
+ */
543
+ var TextDecoderStream: typeof globalThis extends { onmessage: any; TextDecoderStream: infer T } ? T
544
+ : typeof import("stream/web").TextDecoderStream;
545
+
546
+ interface TextEncoderStream extends _TextEncoderStream {}
547
+ /**
548
+ * `TextEncoderStream` class is a global reference for `require('stream/web').TextEncoderStream`.
549
+ * https://nodejs.org/api/globals.html#class-textencoderstream
550
+ * @since v18.0.0
551
+ */
552
+ var TextEncoderStream: typeof globalThis extends { onmessage: any; TextEncoderStream: infer T } ? T
553
+ : typeof import("stream/web").TextEncoderStream;
554
+
555
+ interface TransformStream<I = any, O = any> extends _TransformStream<I, O> {}
556
+ /**
557
+ * `TransformStream` class is a global reference for `require('stream/web').TransformStream`.
558
+ * https://nodejs.org/api/globals.html#class-transformstream
559
+ * @since v18.0.0
560
+ */
561
+ var TransformStream: typeof globalThis extends { onmessage: any; TransformStream: infer T } ? T
562
+ : typeof import("stream/web").TransformStream;
563
+
564
+ interface TransformStreamDefaultController<O = any> extends _TransformStreamDefaultController<O> {}
565
+ /**
566
+ * `TransformStreamDefaultController` class is a global reference for `require('stream/web').TransformStreamDefaultController`.
567
+ * https://nodejs.org/api/globals.html#class-transformstreamdefaultcontroller
568
+ * @since v18.0.0
569
+ */
570
+ var TransformStreamDefaultController: typeof globalThis extends
571
+ { onmessage: any; TransformStreamDefaultController: infer T } ? T
572
+ : typeof import("stream/web").TransformStreamDefaultController;
573
+
574
+ interface WritableStream<W = any> extends _WritableStream<W> {}
575
+ /**
576
+ * `WritableStream` class is a global reference for `require('stream/web').WritableStream`.
577
+ * https://nodejs.org/api/globals.html#class-writablestream
578
+ * @since v18.0.0
579
+ */
580
+ var WritableStream: typeof globalThis extends { onmessage: any; WritableStream: infer T } ? T
581
+ : typeof import("stream/web").WritableStream;
582
+
583
+ interface WritableStreamDefaultController extends _WritableStreamDefaultController {}
584
+ /**
585
+ * `WritableStreamDefaultController` class is a global reference for `require('stream/web').WritableStreamDefaultController`.
586
+ * https://nodejs.org/api/globals.html#class-writablestreamdefaultcontroller
587
+ * @since v18.0.0
588
+ */
589
+ var WritableStreamDefaultController: typeof globalThis extends
590
+ { onmessage: any; WritableStreamDefaultController: infer T } ? T
591
+ : typeof import("stream/web").WritableStreamDefaultController;
592
+
593
+ interface WritableStreamDefaultWriter<W = any> extends _WritableStreamDefaultWriter<W> {}
594
+ /**
595
+ * `WritableStreamDefaultWriter` class is a global reference for `require('stream/web').WritableStreamDefaultWriter`.
596
+ * https://nodejs.org/api/globals.html#class-writablestreamdefaultwriter
597
+ * @since v18.0.0
598
+ */
599
+ var WritableStreamDefaultWriter: typeof globalThis extends
600
+ { onmessage: any; WritableStreamDefaultWriter: infer T } ? T
601
+ : typeof import("stream/web").WritableStreamDefaultWriter;
602
+ }
364
603
  }
365
604
  declare module "node:stream/web" {
366
605
  export * from "stream/web";
node/test.d.ts CHANGED
@@ -484,32 +484,36 @@ declare module "node:test" {
484
484
  readonly assert: TestContextAssert;
485
485
  /**
486
486
  * This function is used to create a hook running before subtest of the current test.
487
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
487
+ * @param fn The hook function. The first argument to this function is a `TestContext` object.
488
+ * If the hook uses callbacks, the callback function is passed as the second argument.
488
489
  * @param options Configuration options for the hook.
489
- * @since v20.1.0
490
+ * @since v20.1.0, v18.17.0
490
491
  */
491
- before: typeof before;
492
+ before(fn?: TestContextHookFn, options?: HookOptions): void;
492
493
  /**
493
494
  * This function is used to create a hook running before each subtest of the current test.
494
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
495
+ * @param fn The hook function. The first argument to this function is a `TestContext` object.
496
+ * If the hook uses callbacks, the callback function is passed as the second argument.
495
497
  * @param options Configuration options for the hook.
496
498
  * @since v18.8.0
497
499
  */
498
- beforeEach: typeof beforeEach;
500
+ beforeEach(fn?: TestContextHookFn, options?: HookOptions): void;
499
501
  /**
500
502
  * This function is used to create a hook that runs after the current test finishes.
501
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
503
+ * @param fn The hook function. The first argument to this function is a `TestContext` object.
504
+ * If the hook uses callbacks, the callback function is passed as the second argument.
502
505
  * @param options Configuration options for the hook.
503
506
  * @since v18.13.0
504
507
  */
505
- after: typeof after;
508
+ after(fn?: TestContextHookFn, options?: HookOptions): void;
506
509
  /**
507
510
  * This function is used to create a hook running after each subtest of the current test.
508
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
511
+ * @param fn The hook function. The first argument to this function is a `TestContext` object.
512
+ * If the hook uses callbacks, the callback function is passed as the second argument.
509
513
  * @param options Configuration options for the hook.
510
514
  * @since v18.8.0
511
515
  */
512
- afterEach: typeof afterEach;
516
+ afterEach(fn?: TestContextHookFn, options?: HookOptions): void;
513
517
  /**
514
518
  * This function is used to write diagnostics to the output. Any diagnostic
515
519
  * information is included at the end of the test's results. This function does
@@ -880,10 +884,15 @@ declare module "node:test" {
880
884
  */
881
885
  function afterEach(fn?: HookFn, options?: HookOptions): void;
882
886
  /**
883
- * The hook function. If the hook uses callbacks, the callback function is passed as the
884
- * second argument.
887
+ * The hook function. The first argument is the context in which the hook is called.
888
+ * If the hook uses callbacks, the callback function is passed as the second argument.
885
889
  */
886
- type HookFn = (s: SuiteContext, done: (result?: any) => void) => any;
890
+ type HookFn = (c: TestContext | SuiteContext, done: (result?: any) => void) => any;
891
+ /**
892
+ * The hook function. The first argument is a `TestContext` object.
893
+ * If the hook uses callbacks, the callback function is passed as the second argument.
894
+ */
895
+ type TestContextHookFn = (t: TestContext, done: (result?: any) => void) => any;
887
896
  /**
888
897
  * Configuration options for hooks.
889
898
  * @since v18.8.0