@types/node 18.16.0 → 18.16.2

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/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sun, 23 Apr 2023 05:02:41 GMT
11
+ * Last updated: Thu, 27 Apr 2023 21:32:47 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
14
 
node/globals.d.ts CHANGED
@@ -159,7 +159,7 @@ declare namespace NodeJS {
159
159
  /**
160
160
  * Name of the script [if this function was defined in a script]
161
161
  */
162
- getFileName(): string | null;
162
+ getFileName(): string | undefined;
163
163
 
164
164
  /**
165
165
  * Current line number [if this function was defined in a script]
node/http.d.ts CHANGED
@@ -345,6 +345,7 @@ declare module 'http' {
345
345
  event: 'connect',
346
346
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
347
347
  ): this;
348
+ addListener(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
348
349
  addListener(event: 'request', listener: RequestListener<Request, Response>): this;
349
350
  addListener(
350
351
  event: 'upgrade',
@@ -367,6 +368,7 @@ declare module 'http' {
367
368
  ): boolean;
368
369
  emit(event: 'clientError', err: Error, socket: stream.Duplex): boolean;
369
370
  emit(event: 'connect', req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
371
+ emit(event: 'dropRequest', req: InstanceType<Request>, socket: stream.Duplex): boolean;
370
372
  emit(
371
373
  event: 'request',
372
374
  req: InstanceType<Request>,
@@ -382,6 +384,7 @@ declare module 'http' {
382
384
  on(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
383
385
  on(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
384
386
  on(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
387
+ on(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
385
388
  on(event: 'request', listener: RequestListener<Request, Response>): this;
386
389
  on(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
387
390
  once(event: string, listener: (...args: any[]) => void): this;
@@ -396,6 +399,7 @@ declare module 'http' {
396
399
  event: 'connect',
397
400
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
398
401
  ): this;
402
+ once(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
399
403
  once(event: 'request', listener: RequestListener<Request, Response>): this;
400
404
  once(
401
405
  event: 'upgrade',
@@ -413,6 +417,10 @@ declare module 'http' {
413
417
  event: 'connect',
414
418
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
415
419
  ): this;
420
+ prependListener(
421
+ event: 'dropRequest',
422
+ listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
423
+ ): this;
416
424
  prependListener(event: 'request', listener: RequestListener<Request, Response>): this;
417
425
  prependListener(
418
426
  event: 'upgrade',
@@ -430,6 +438,10 @@ declare module 'http' {
430
438
  event: 'connect',
431
439
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
432
440
  ): this;
441
+ prependOnceListener(
442
+ event: 'dropRequest',
443
+ listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
444
+ ): this;
433
445
  prependOnceListener(event: 'request', listener: RequestListener<Request, Response>): this;
434
446
  prependOnceListener(
435
447
  event: 'upgrade',
@@ -479,11 +491,26 @@ declare module 'http' {
479
491
  setTimeout(msecs: number, callback?: () => void): this;
480
492
  /**
481
493
  * Sets a single header value for the header object.
494
+ * If the header already exists in the to-be-sent headers, its value will be replaced. Use an array of strings to send multiple headers with the same name.
482
495
  * @since v0.4.0
483
496
  * @param name Header name
484
497
  * @param value Header value
485
498
  */
486
499
  setHeader(name: string, value: number | string | ReadonlyArray<string>): this;
500
+ /**
501
+ * Append a single header value for the header object.
502
+ *
503
+ * If the value is an array, this is equivalent of calling this method multiple times.
504
+ *
505
+ * If there were no previous value for the header, this is equivalent of calling `outgoingMessage.setHeader(name, value)`.
506
+ *
507
+ * Depending of the value of `options.uniqueHeaders` when the client request or the server were created,
508
+ * this will end up in the header being sent multiple times or a single time with values joined using `; `.
509
+ * @since v18.3.0, v16.17.0
510
+ * @param name Header name
511
+ * @param value Header value
512
+ */
513
+ appendHeader(name: string, value: string | ReadonlyArray<string>): this;
487
514
  /**
488
515
  * Gets the value of HTTP header with the given name. If such a name doesn't
489
516
  * exist in message, it will be `undefined`.
@@ -610,6 +637,14 @@ declare module 'http' {
610
637
  * @since v0.11.8
611
638
  */
612
639
  statusMessage: string;
640
+ /**
641
+ * If set to `true`, Node.js will check whether the `Content-Length` header value
642
+ * and the size of the body, in bytes, are equal. Mismatching the
643
+ * `Content-Length` header value will result in an `Error` being thrown,
644
+ * identified by `code: 'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
645
+ * @since v18.10.0, v16.18.0
646
+ */
647
+ strictContentLength: boolean;
613
648
  constructor(req: Request);
614
649
  assignSocket(socket: Socket): void;
615
650
  detachSocket(socket: Socket): void;
@@ -1090,6 +1125,20 @@ declare module 'http' {
1090
1125
  * @since v0.1.5
1091
1126
  */
1092
1127
  headers: IncomingHttpHeaders;
1128
+ /**
1129
+ * Similar to `message.headers`, but there is no join logic and the values are always arrays of strings, even for headers received just once.
1130
+ *
1131
+ * ```js
1132
+ * // Prints something like:
1133
+ * //
1134
+ * // { 'user-agent': ['curl/7.22.0'],
1135
+ * // host: ['127.0.0.1:8000'],
1136
+ * // accept: ['*'] }
1137
+ * console.log(request.headersDistinct);
1138
+ * ```
1139
+ * @since v18.3.0, v16.17.0
1140
+ */
1141
+ headersDistinct: NodeJS.Dict<string[]>;
1093
1142
  /**
1094
1143
  * The raw request/response headers list exactly as they were received.
1095
1144
  *
@@ -1120,6 +1169,12 @@ declare module 'http' {
1120
1169
  * @since v0.3.0
1121
1170
  */
1122
1171
  trailers: NodeJS.Dict<string>;
1172
+ /**
1173
+ * Similar to `message.trailers`, but there is no join logic and the values are always arrays of strings, even for headers received just once.
1174
+ * Only populated at the `'end'` event.
1175
+ * @since v18.3.0, v16.17.0
1176
+ */
1177
+ trailersDistinct: NodeJS.Dict<string[]>;
1123
1178
  /**
1124
1179
  * The raw request/response trailer keys and values exactly as they were
1125
1180
  * received. Only populated at the `'end'` event.
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.16.0",
3
+ "version": "18.16.2",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -232,6 +232,6 @@
232
232
  },
233
233
  "scripts": {},
234
234
  "dependencies": {},
235
- "typesPublisherContentHash": "a33ada7d817296d3a0955f57b75fdf38201a158b99b66db3bb81316dfddd470b",
235
+ "typesPublisherContentHash": "4a9603f50e5b72ce1a4b35ed8eae48f4e9a4179f00f36f502b322e60c56733df",
236
236
  "typeScriptVersion": "4.3"
237
237
  }
node/ts4.8/v8.d.ts CHANGED
@@ -441,6 +441,100 @@ declare module 'v8' {
441
441
  spaceAvailableSize: number;
442
442
  physicalSpaceSize: number;
443
443
  }
444
+ /**
445
+ * Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will
446
+ * happen if a promise is created without ever getting a continuation.
447
+ * @since v17.1.0, v16.14.0
448
+ * @param promise The promise being created.
449
+ * @param parent The promise continued from, if applicable.
450
+ */
451
+ interface Init {
452
+ (promise: Promise<unknown>, parent: Promise<unknown>): void;
453
+ }
454
+ /**
455
+ * Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming.
456
+ *
457
+ * The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise.
458
+ * The before callback may be called many times in the case where many continuations have been made from the same promise.
459
+ * @since v17.1.0, v16.14.0
460
+ */
461
+ interface Before {
462
+ (promise: Promise<unknown>): void;
463
+ }
464
+ /**
465
+ * Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await.
466
+ * @since v17.1.0, v16.14.0
467
+ */
468
+ interface After {
469
+ (promise: Promise<unknown>): void;
470
+ }
471
+ /**
472
+ * Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or
473
+ * {@link Promise.reject()}.
474
+ * @since v17.1.0, v16.14.0
475
+ */
476
+ interface Settled {
477
+ (promise: Promise<unknown>): void;
478
+ }
479
+ /**
480
+ * Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or
481
+ * around an await, and when the promise resolves or rejects.
482
+ *
483
+ * Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and
484
+ * `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop.
485
+ * @since v17.1.0, v16.14.0
486
+ */
487
+ interface HookCallbacks {
488
+ init?: Init;
489
+ before?: Before;
490
+ after?: After;
491
+ settled?: Settled;
492
+ }
493
+ interface PromiseHooks {
494
+ /**
495
+ * The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
496
+ * @since v17.1.0, v16.14.0
497
+ * @param init The {@link Init | `init` callback} to call when a promise is created.
498
+ * @return Call to stop the hook.
499
+ */
500
+ onInit: (init: Init) => Function;
501
+ /**
502
+ * The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
503
+ * @since v17.1.0, v16.14.0
504
+ * @param settled The {@link Settled | `settled` callback} to call when a promise is created.
505
+ * @return Call to stop the hook.
506
+ */
507
+ onSettled: (settled: Settled) => Function;
508
+ /**
509
+ * The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
510
+ * @since v17.1.0, v16.14.0
511
+ * @param before The {@link Before | `before` callback} to call before a promise continuation executes.
512
+ * @return Call to stop the hook.
513
+ */
514
+ onBefore: (before: Before) => Function;
515
+ /**
516
+ * The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
517
+ * @since v17.1.0, v16.14.0
518
+ * @param after The {@link After | `after` callback} to call after a promise continuation executes.
519
+ * @return Call to stop the hook.
520
+ */
521
+ onAfter: (after: After) => Function;
522
+ /**
523
+ * Registers functions to be called for different lifetime events of each promise.
524
+ * The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime.
525
+ * All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed.
526
+ * The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop.
527
+ * @since v17.1.0, v16.14.0
528
+ * @param callbacks The {@link HookCallbacks | Hook Callbacks} to register
529
+ * @return Used for disabling hooks
530
+ */
531
+ createHook: (callbacks: HookCallbacks) => Function;
532
+ }
533
+ /**
534
+ * The `promiseHooks` interface can be used to track promise lifecycle events.
535
+ * @since v17.1.0, v16.14.0
536
+ */
537
+ const promiseHooks: PromiseHooks;
444
538
  }
445
539
  declare module 'node:v8' {
446
540
  export * from 'v8';
node/v8.d.ts CHANGED
@@ -441,6 +441,100 @@ declare module 'v8' {
441
441
  spaceAvailableSize: number;
442
442
  physicalSpaceSize: number;
443
443
  }
444
+ /**
445
+ * Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will
446
+ * happen if a promise is created without ever getting a continuation.
447
+ * @since v17.1.0, v16.14.0
448
+ * @param promise The promise being created.
449
+ * @param parent The promise continued from, if applicable.
450
+ */
451
+ interface Init {
452
+ (promise: Promise<unknown>, parent: Promise<unknown>): void;
453
+ }
454
+ /**
455
+ * Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming.
456
+ *
457
+ * The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise.
458
+ * The before callback may be called many times in the case where many continuations have been made from the same promise.
459
+ * @since v17.1.0, v16.14.0
460
+ */
461
+ interface Before {
462
+ (promise: Promise<unknown>): void;
463
+ }
464
+ /**
465
+ * Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await.
466
+ * @since v17.1.0, v16.14.0
467
+ */
468
+ interface After {
469
+ (promise: Promise<unknown>): void;
470
+ }
471
+ /**
472
+ * Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or
473
+ * {@link Promise.reject()}.
474
+ * @since v17.1.0, v16.14.0
475
+ */
476
+ interface Settled {
477
+ (promise: Promise<unknown>): void;
478
+ }
479
+ /**
480
+ * Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or
481
+ * around an await, and when the promise resolves or rejects.
482
+ *
483
+ * Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and
484
+ * `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop.
485
+ * @since v17.1.0, v16.14.0
486
+ */
487
+ interface HookCallbacks {
488
+ init?: Init;
489
+ before?: Before;
490
+ after?: After;
491
+ settled?: Settled;
492
+ }
493
+ interface PromiseHooks {
494
+ /**
495
+ * The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
496
+ * @since v17.1.0, v16.14.0
497
+ * @param init The {@link Init | `init` callback} to call when a promise is created.
498
+ * @return Call to stop the hook.
499
+ */
500
+ onInit: (init: Init) => Function;
501
+ /**
502
+ * The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
503
+ * @since v17.1.0, v16.14.0
504
+ * @param settled The {@link Settled | `settled` callback} to call when a promise is created.
505
+ * @return Call to stop the hook.
506
+ */
507
+ onSettled: (settled: Settled) => Function;
508
+ /**
509
+ * The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
510
+ * @since v17.1.0, v16.14.0
511
+ * @param before The {@link Before | `before` callback} to call before a promise continuation executes.
512
+ * @return Call to stop the hook.
513
+ */
514
+ onBefore: (before: Before) => Function;
515
+ /**
516
+ * The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
517
+ * @since v17.1.0, v16.14.0
518
+ * @param after The {@link After | `after` callback} to call after a promise continuation executes.
519
+ * @return Call to stop the hook.
520
+ */
521
+ onAfter: (after: After) => Function;
522
+ /**
523
+ * Registers functions to be called for different lifetime events of each promise.
524
+ * The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime.
525
+ * All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed.
526
+ * The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop.
527
+ * @since v17.1.0, v16.14.0
528
+ * @param callbacks The {@link HookCallbacks | Hook Callbacks} to register
529
+ * @return Used for disabling hooks
530
+ */
531
+ createHook: (callbacks: HookCallbacks) => Function;
532
+ }
533
+ /**
534
+ * The `promiseHooks` interface can be used to track promise lifecycle events.
535
+ * @since v17.1.0, v16.14.0
536
+ */
537
+ const promiseHooks: PromiseHooks;
444
538
  }
445
539
  declare module 'node:v8' {
446
540
  export * from 'v8';