@types/node 18.19.47 → 18.19.49

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 v18.19/https.d.ts CHANGED
@@ -10,7 +10,9 @@ declare module "https" {
10
10
  import { URL } from "node:url";
11
11
  type ServerOptions<
12
12
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
13
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
13
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
14
+ InstanceType<Request>
15
+ >,
14
16
  > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
15
17
  type RequestOptions =
16
18
  & http.RequestOptions
@@ -34,7 +36,9 @@ declare module "https" {
34
36
  }
35
37
  interface Server<
36
38
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
37
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
39
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
40
+ InstanceType<Request>
41
+ >,
38
42
  > extends http.Server<Request, Response> {}
39
43
  /**
40
44
  * See `http.Server` for more information.
@@ -42,7 +46,9 @@ declare module "https" {
42
46
  */
43
47
  class Server<
44
48
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
45
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
49
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
50
+ InstanceType<Request>
51
+ >,
46
52
  > extends tls.Server {
47
53
  constructor(requestListener?: http.RequestListener<Request, Response>);
48
54
  constructor(
@@ -119,19 +125,19 @@ declare module "https" {
119
125
  emit(
120
126
  event: "checkContinue",
121
127
  req: InstanceType<Request>,
122
- res: InstanceType<Response> & { req: InstanceType<Request> },
128
+ res: InstanceType<Response>,
123
129
  ): boolean;
124
130
  emit(
125
131
  event: "checkExpectation",
126
132
  req: InstanceType<Request>,
127
- res: InstanceType<Response> & { req: InstanceType<Request> },
133
+ res: InstanceType<Response>,
128
134
  ): boolean;
129
135
  emit(event: "clientError", err: Error, socket: Duplex): boolean;
130
136
  emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
131
137
  emit(
132
138
  event: "request",
133
139
  req: InstanceType<Request>,
134
- res: InstanceType<Response> & { req: InstanceType<Request> },
140
+ res: InstanceType<Response>,
135
141
  ): boolean;
136
142
  emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
137
143
  on(event: string, listener: (...args: any[]) => void): this;
@@ -306,11 +312,15 @@ declare module "https" {
306
312
  */
307
313
  function createServer<
308
314
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
309
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
315
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
316
+ InstanceType<Request>
317
+ >,
310
318
  >(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
311
319
  function createServer<
312
320
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
313
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
321
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
322
+ InstanceType<Request>
323
+ >,
314
324
  >(
315
325
  options: ServerOptions<Request, Response>,
316
326
  requestListener?: http.RequestListener<Request, Response>,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.19.47",
3
+ "version": "18.19.49",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -217,6 +217,6 @@
217
217
  "dependencies": {
218
218
  "undici-types": "~5.26.4"
219
219
  },
220
- "typesPublisherContentHash": "d1f247a2b67ea5d8676a67452a9d6d88919b6c5938bf06bf1e6f689cf3b02713",
220
+ "typesPublisherContentHash": "24d0a779b9e50f4a93468e6f68fe1dd999036f683818b114d727cd86ee1d0391",
221
221
  "typeScriptVersion": "4.8"
222
222
  }
@@ -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,16 @@ declare module "stream/web" {
65
100
  readonly closed: Promise<undefined>;
66
101
  cancel(reason?: any): Promise<void>;
67
102
  }
68
- interface ReadableStreamDefaultReadValueResult<T> {
103
+ type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
104
+ interface ReadableStreamReadValueResult<T> {
69
105
  done: false;
70
106
  value: T;
71
107
  }
72
- interface ReadableStreamDefaultReadDoneResult {
108
+ interface ReadableStreamReadDoneResult<T> {
73
109
  done: true;
74
- value?: undefined;
110
+ value?: T;
75
111
  }
76
- type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
77
- type ReadableStreamDefaultReadResult<T> =
78
- | ReadableStreamDefaultReadValueResult<T>
79
- | ReadableStreamDefaultReadDoneResult;
112
+ type ReadableStreamReadResult<T> = ReadableStreamReadValueResult<T> | ReadableStreamReadDoneResult<T>;
80
113
  interface ReadableByteStreamControllerCallback {
81
114
  (controller: ReadableByteStreamController): void | PromiseLike<void>;
82
115
  }
@@ -137,7 +170,9 @@ declare module "stream/web" {
137
170
  interface ReadableStream<R = any> {
138
171
  readonly locked: boolean;
139
172
  cancel(reason?: any): Promise<void>;
173
+ getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
140
174
  getReader(): ReadableStreamDefaultReader<R>;
175
+ getReader(options?: ReadableStreamGetReaderOptions): ReadableStreamReader<R>;
141
176
  pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
142
177
  pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
143
178
  tee(): [ReadableStream<R>, ReadableStream<R>];
@@ -149,16 +184,48 @@ declare module "stream/web" {
149
184
  new(underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
150
185
  new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
151
186
  };
187
+ type ReadableStreamReaderMode = "byob";
188
+ interface ReadableStreamGetReaderOptions {
189
+ /**
190
+ * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
191
+ *
192
+ * 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.
193
+ */
194
+ mode?: ReadableStreamReaderMode;
195
+ }
196
+ type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBYOBReader;
152
197
  interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
153
- read(): Promise<ReadableStreamDefaultReadResult<R>>;
198
+ read(): Promise<ReadableStreamReadResult<R>>;
199
+ releaseLock(): void;
200
+ }
201
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
202
+ interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
203
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
204
+ read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
205
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
154
206
  releaseLock(): void;
155
207
  }
156
208
  const ReadableStreamDefaultReader: {
157
209
  prototype: ReadableStreamDefaultReader;
158
210
  new<R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
159
211
  };
160
- const ReadableStreamBYOBReader: any;
161
- const ReadableStreamBYOBRequest: any;
212
+ const ReadableStreamBYOBReader: {
213
+ prototype: ReadableStreamBYOBReader;
214
+ new(stream: ReadableStream): ReadableStreamBYOBReader;
215
+ };
216
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */
217
+ interface ReadableStreamBYOBRequest {
218
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */
219
+ readonly view: ArrayBufferView | null;
220
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */
221
+ respond(bytesWritten: number): void;
222
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */
223
+ respondWithNewView(view: ArrayBufferView): void;
224
+ }
225
+ const ReadableStreamBYOBRequest: {
226
+ prototype: ReadableStreamBYOBRequest;
227
+ new(): ReadableStreamBYOBRequest;
228
+ };
162
229
  interface ReadableByteStreamController {
163
230
  readonly byobRequest: undefined;
164
231
  readonly desiredSize: number | null;
@@ -330,22 +397,123 @@ declare module "stream/web" {
330
397
  prototype: TextDecoderStream;
331
398
  new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream;
332
399
  };
333
- interface CompressionStream<R = any, W = any> {
334
- readonly readable: ReadableStream<R>;
335
- readonly writable: WritableStream<W>;
400
+ interface CompressionStream {
401
+ readonly readable: ReadableStream;
402
+ readonly writable: WritableStream;
336
403
  }
337
404
  const CompressionStream: {
338
405
  prototype: CompressionStream;
339
- new<R = any, W = any>(format: string): CompressionStream<R, W>;
406
+ new(format: "deflate" | "deflate-raw" | "gzip"): CompressionStream;
340
407
  };
341
- interface DecompressionStream<R = any, W = any> {
342
- readonly readable: ReadableStream<R>;
343
- readonly writable: WritableStream<W>;
408
+ interface DecompressionStream {
409
+ readonly writable: WritableStream;
410
+ readonly readable: ReadableStream;
344
411
  }
345
412
  const DecompressionStream: {
346
413
  prototype: DecompressionStream;
347
- new<R = any, W = any>(format: string): DecompressionStream<R, W>;
414
+ new(format: "deflate" | "deflate-raw" | "gzip"): DecompressionStream;
348
415
  };
416
+
417
+ global {
418
+ interface ByteLengthQueuingStrategy extends _ByteLengthQueuingStrategy {}
419
+ var ByteLengthQueuingStrategy: typeof globalThis extends { onmessage: any; ByteLengthQueuingStrategy: infer T }
420
+ ? T
421
+ : typeof import("stream/web").ByteLengthQueuingStrategy;
422
+
423
+ interface CompressionStream extends _CompressionStream {}
424
+ var CompressionStream: typeof globalThis extends {
425
+ onmessage: any;
426
+ // CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
427
+ // If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
428
+ ReportingObserver: any;
429
+ CompressionStream: infer T;
430
+ } ? T
431
+ // TS 4.8, 4.9, 5.0
432
+ : typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
433
+ prototype: T;
434
+ new(format: "deflate" | "deflate-raw" | "gzip"): T;
435
+ }
436
+ : typeof import("stream/web").CompressionStream;
437
+
438
+ interface CountQueuingStrategy extends _CountQueuingStrategy {}
439
+ var CountQueuingStrategy: typeof globalThis extends { onmessage: any; CountQueuingStrategy: infer T } ? T
440
+ : typeof import("stream/web").CountQueuingStrategy;
441
+
442
+ interface DecompressionStream extends _DecompressionStream {}
443
+ var DecompressionStream: typeof globalThis extends {
444
+ onmessage: any;
445
+ // CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
446
+ // If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
447
+ ReportingObserver: any;
448
+ DecompressionStream: infer T;
449
+ } ? T
450
+ // TS 4.8, 4.9, 5.0
451
+ : typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
452
+ prototype: T;
453
+ new(format: "deflate" | "deflate-raw" | "gzip"): T;
454
+ }
455
+ : typeof import("stream/web").DecompressionStream;
456
+
457
+ interface ReadableByteStreamController extends _ReadableByteStreamController {}
458
+ var ReadableByteStreamController: typeof globalThis extends
459
+ { onmessage: any; ReadableByteStreamController: infer T } ? T
460
+ : typeof import("stream/web").ReadableByteStreamController;
461
+
462
+ interface ReadableStream<R = any> extends _ReadableStream<R> {}
463
+ var ReadableStream: typeof globalThis extends { onmessage: any; ReadableStream: infer T } ? T
464
+ : typeof import("stream/web").ReadableStream;
465
+
466
+ interface ReadableStreamBYOBReader extends _ReadableStreamBYOBReader {}
467
+ var ReadableStreamBYOBReader: typeof globalThis extends { onmessage: any; ReadableStreamBYOBReader: infer T }
468
+ ? T
469
+ : typeof import("stream/web").ReadableStreamBYOBReader;
470
+
471
+ interface ReadableStreamBYOBRequest extends _ReadableStreamBYOBRequest {}
472
+ var ReadableStreamBYOBRequest: typeof globalThis extends { onmessage: any; ReadableStreamBYOBRequest: infer T }
473
+ ? T
474
+ : typeof import("stream/web").ReadableStreamBYOBRequest;
475
+
476
+ interface ReadableStreamDefaultController<R = any> extends _ReadableStreamDefaultController<R> {}
477
+ var ReadableStreamDefaultController: typeof globalThis extends
478
+ { onmessage: any; ReadableStreamDefaultController: infer T } ? T
479
+ : typeof import("stream/web").ReadableStreamDefaultController;
480
+
481
+ interface ReadableStreamDefaultReader<R = any> extends _ReadableStreamDefaultReader<R> {}
482
+ var ReadableStreamDefaultReader: typeof globalThis extends
483
+ { onmessage: any; ReadableStreamDefaultReader: infer T } ? T
484
+ : typeof import("stream/web").ReadableStreamDefaultReader;
485
+
486
+ interface TextDecoderStream extends _TextDecoderStream {}
487
+ var TextDecoderStream: typeof globalThis extends { onmessage: any; TextDecoderStream: infer T } ? T
488
+ : typeof import("stream/web").TextDecoderStream;
489
+
490
+ interface TextEncoderStream extends _TextEncoderStream {}
491
+ var TextEncoderStream: typeof globalThis extends { onmessage: any; TextEncoderStream: infer T } ? T
492
+ : typeof import("stream/web").TextEncoderStream;
493
+
494
+ interface TransformStream<I = any, O = any> extends _TransformStream<I, O> {}
495
+ var TransformStream: typeof globalThis extends { onmessage: any; TransformStream: infer T } ? T
496
+ : typeof import("stream/web").TransformStream;
497
+
498
+ interface TransformStreamDefaultController<O = any> extends _TransformStreamDefaultController<O> {}
499
+ var TransformStreamDefaultController: typeof globalThis extends
500
+ { onmessage: any; TransformStreamDefaultController: infer T } ? T
501
+ : typeof import("stream/web").TransformStreamDefaultController;
502
+
503
+ interface WritableStream<W = any> extends _WritableStream<W> {}
504
+ var WritableStream: typeof globalThis extends { onmessage: any; WritableStream: infer T } ? T
505
+ : typeof import("stream/web").WritableStream;
506
+
507
+ interface WritableStreamDefaultController extends _WritableStreamDefaultController {}
508
+ var WritableStreamDefaultController: typeof globalThis extends
509
+ { onmessage: any; WritableStreamDefaultController: infer T } ? T
510
+ : typeof import("stream/web").WritableStreamDefaultController;
511
+
512
+ interface WritableStreamDefaultWriter<W = any> extends _WritableStreamDefaultWriter<W> {}
513
+ var WritableStreamDefaultWriter: typeof globalThis extends
514
+ { onmessage: any; WritableStreamDefaultWriter: infer T } ? T
515
+ : typeof import("stream/web").WritableStreamDefaultWriter;
516
+ }
349
517
  }
350
518
  declare module "node:stream/web" {
351
519
  export * from "stream/web";
node v18.19/test.d.ts CHANGED
@@ -315,39 +315,39 @@ declare module "node:test" {
315
315
  export interface TestContext {
316
316
  /**
317
317
  * This function is used to create a hook running before subtest of the current test.
318
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
319
- * the second argument. Default: A no-op function.
318
+ * @param fn The hook function. The first argument to this function is a `TestContext` object.
319
+ * If the hook uses callbacks, the callback function is passed as the second argument.
320
320
  * @param options Configuration options for the hook.
321
321
  * @since v18.17.0
322
322
  */
323
- before: typeof before;
323
+ before(fn?: TestContextHookFn, options?: HookOptions): void;
324
324
 
325
325
  /**
326
326
  * This function is used to create a hook running before each subtest of the current test.
327
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
328
- * the second argument. Default: A no-op function.
327
+ * @param fn The hook function. The first argument to this function is a `TestContext` object.
328
+ * If the hook uses callbacks, the callback function is passed as the second argument.
329
329
  * @param options Configuration options for the hook.
330
330
  * @since v18.8.0
331
331
  */
332
- beforeEach: typeof beforeEach;
332
+ beforeEach(fn?: TestContextHookFn, options?: HookOptions): void;
333
333
 
334
334
  /**
335
335
  * This function is used to create a hook that runs after the current test finishes.
336
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
337
- * the second argument. Default: A no-op function.
336
+ * @param fn The hook function. The first argument to this function is a `TestContext` object.
337
+ * If the hook uses callbacks, the callback function is passed as the second argument.
338
338
  * @param options Configuration options for the hook.
339
339
  * @since v18.13.0
340
340
  */
341
- after: typeof after;
341
+ after(fn?: TestContextHookFn, options?: HookOptions): void;
342
342
 
343
343
  /**
344
344
  * This function is used to create a hook running after each subtest of the current test.
345
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
346
- * the second argument. Default: A no-op function.
345
+ * @param fn The hook function. The first argument to this function is a `TestContext` object.
346
+ * If the hook uses callbacks, the callback function is passed as the second argument.
347
347
  * @param options Configuration options for the hook.
348
348
  * @since v18.8.0
349
349
  */
350
- afterEach: typeof afterEach;
350
+ afterEach(fn?: TestContextHookFn, options?: HookOptions): void;
351
351
 
352
352
  /**
353
353
  * This function is used to write diagnostics to the output. Any diagnostic information is
@@ -517,10 +517,16 @@ declare module "node:test" {
517
517
  function afterEach(fn?: HookFn, options?: HookOptions): void;
518
518
 
519
519
  /**
520
- * The hook function. If the hook uses callbacks, the callback function is passed as the
521
- * second argument.
520
+ * The hook function. The first argument is the context in which the hook is called.
521
+ * If the hook uses callbacks, the callback function is passed as the second argument.
522
522
  */
523
- type HookFn = (s: SuiteContext, done: (result?: any) => void) => any;
523
+ type HookFn = (c: TestContext | SuiteContext, done: (result?: any) => void) => any;
524
+
525
+ /**
526
+ * The hook function. The first argument is a `TestContext` object.
527
+ * If the hook uses callbacks, the callback function is passed as the second argument.
528
+ */
529
+ type TestContextHookFn = (t: TestContext, done: (result?: any) => void) => any;
524
530
 
525
531
  /**
526
532
  * Configuration options for hooks.