@types/node 16.18.105 → 16.18.107

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 v16.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/v16.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Fri, 09 Aug 2024 18:08:59 GMT
11
+ * Last updated: Wed, 04 Sep 2024 00:28:08 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
node v16.18/buffer.d.ts CHANGED
@@ -356,9 +356,9 @@ declare module "buffer" {
356
356
  encoding?: BufferEncoding,
357
357
  ): number;
358
358
  /**
359
- * Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together.
359
+ * Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
360
360
  *
361
- * If the list has no items, or if the `totalLength` is 0, then a new zero-length`Buffer` is returned.
361
+ * If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
362
362
  *
363
363
  * If `totalLength` is not provided, it is calculated from the `Buffer` instances
364
364
  * in `list` by adding their lengths.
node v16.18/http.d.ts CHANGED
@@ -225,7 +225,7 @@ declare module "http" {
225
225
  }
226
226
  interface ServerOptions<
227
227
  Request extends typeof IncomingMessage = typeof IncomingMessage,
228
- Response extends typeof ServerResponse = typeof ServerResponse,
228
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
229
229
  > {
230
230
  IncomingMessage?: Request | undefined;
231
231
  ServerResponse?: Response | undefined;
@@ -265,14 +265,14 @@ declare module "http" {
265
265
  }
266
266
  type RequestListener<
267
267
  Request extends typeof IncomingMessage = typeof IncomingMessage,
268
- Response extends typeof ServerResponse = typeof ServerResponse,
268
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
269
269
  > = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
270
270
  /**
271
271
  * @since v0.1.17
272
272
  */
273
273
  class Server<
274
274
  Request extends typeof IncomingMessage = typeof IncomingMessage,
275
- Response extends typeof ServerResponse = typeof ServerResponse,
275
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
276
276
  > extends NetServer {
277
277
  constructor(requestListener?: RequestListener<Request, Response>);
278
278
  constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
@@ -1287,12 +1287,15 @@ declare module "http" {
1287
1287
  */
1288
1288
  function createServer<
1289
1289
  Request extends typeof IncomingMessage = typeof IncomingMessage,
1290
- Response extends typeof ServerResponse = typeof ServerResponse,
1290
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
1291
1291
  >(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
1292
1292
  function createServer<
1293
1293
  Request extends typeof IncomingMessage = typeof IncomingMessage,
1294
- Response extends typeof ServerResponse = typeof ServerResponse,
1295
- >(options: ServerOptions, requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
1294
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
1295
+ >(
1296
+ options: ServerOptions<Request, Response>,
1297
+ requestListener?: RequestListener<Request, Response>,
1298
+ ): Server<Request, Response>;
1296
1299
  // although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
1297
1300
  // create interface RequestOptions would make the naming more clear to developers
1298
1301
  interface RequestOptions extends ClientRequestArgs {}
node v16.18/http2.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The `http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol. It
3
- * can be accessed using:
2
+ * The `http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol.
3
+ * It can be accessed using:
4
4
  *
5
5
  * ```js
6
6
  * const http2 = require('http2');
@@ -96,7 +96,7 @@ declare module "http2" {
96
96
  */
97
97
  readonly endAfterHeaders: boolean;
98
98
  /**
99
- * The numeric stream identifier of this `Http2Stream` instance. Set to `undefined`if the stream identifier has not yet been assigned.
99
+ * The numeric stream identifier of this `Http2Stream` instance. Set to `undefined` if the stream identifier has not yet been assigned.
100
100
  * @since v8.4.0
101
101
  */
102
102
  readonly id?: number | undefined;
@@ -109,7 +109,7 @@ declare module "http2" {
109
109
  /**
110
110
  * Set to the `RST_STREAM` `error code` reported when the `Http2Stream` is
111
111
  * destroyed after either receiving an `RST_STREAM` frame from the connected peer,
112
- * calling `http2stream.close()`, or `http2stream.destroy()`. Will be`undefined` if the `Http2Stream` has not been closed.
112
+ * calling `http2stream.close()`, or `http2stream.destroy()`. Will be `undefined` if the `Http2Stream` has not been closed.
113
113
  * @since v8.4.0
114
114
  */
115
115
  readonly rstCode: number;
@@ -136,7 +136,7 @@ declare module "http2" {
136
136
  */
137
137
  readonly session: Http2Session | undefined;
138
138
  /**
139
- * Provides miscellaneous information about the current state of the`Http2Stream`.
139
+ * Provides miscellaneous information about the current state of the `Http2Stream`.
140
140
  *
141
141
  * A current state of this `Http2Stream`.
142
142
  * @since v8.4.0
@@ -355,7 +355,7 @@ declare module "http2" {
355
355
  /**
356
356
  * Read-only property mapped to the `SETTINGS_ENABLE_PUSH` flag of the remote
357
357
  * client's most recent `SETTINGS` frame. Will be `true` if the remote peer
358
- * accepts push streams, `false` otherwise. Settings are the same for every`Http2Stream` in the same `Http2Session`.
358
+ * accepts push streams, `false` otherwise. Settings are the same for every `Http2Stream` in the same `Http2Session`.
359
359
  * @since v8.4.0
360
360
  */
361
361
  readonly pushAllowed: boolean;
@@ -365,7 +365,7 @@ declare module "http2" {
365
365
  */
366
366
  additionalHeaders(headers: OutgoingHttpHeaders): void;
367
367
  /**
368
- * Initiates a push stream. The callback is invoked with the new `Http2Stream`instance created for the push stream passed as the second argument, or an`Error` passed as the first argument.
368
+ * Initiates a push stream. The callback is invoked with the new `Http2Stream` instance created for the push stream passed as the second argument, or an `Error` passed as the first argument.
369
369
  *
370
370
  * ```js
371
371
  * const http2 = require('http2');
@@ -382,7 +382,7 @@ declare module "http2" {
382
382
  * ```
383
383
  *
384
384
  * Setting the weight of a push stream is not allowed in the `HEADERS` frame. Pass
385
- * a `weight` value to `http2stream.priority` with the `silent` option set to`true` to enable server-side bandwidth balancing between concurrent streams.
385
+ * a `weight` value to `http2stream.priority` with the `silent` option set to `true` to enable server-side bandwidth balancing between concurrent streams.
386
386
  *
387
387
  * Calling `http2stream.pushStream()` from within a pushed stream is not permitted
388
388
  * and will throw an error.
@@ -408,13 +408,12 @@ declare module "http2" {
408
408
  * });
409
409
  * ```
410
410
  *
411
- * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
412
- * will be emitted immediately after queuing the last chunk of payload data to be
413
- * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing
414
- * header fields to the peer.
411
+ * Initiates a response. When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
412
+ * will be emitted immediately after queuing the last chunk of payload data to be sent.
413
+ * The `http2stream.sendTrailers()` method can then be used to send trailing header fields to the peer.
415
414
  *
416
415
  * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
417
- * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
416
+ * close when the final `DATA` frame is transmitted. User code must call either `http2stream.sendTrailers()` or `http2stream.close()` to close the `Http2Stream`.
418
417
  *
419
418
  * ```js
420
419
  * const http2 = require('http2');
@@ -451,7 +450,7 @@ declare module "http2" {
451
450
  * const headers = {
452
451
  * 'content-length': stat.size,
453
452
  * 'last-modified': stat.mtime.toUTCString(),
454
- * 'content-type': 'text/plain; charset=utf-8'
453
+ * 'content-type': 'text/plain; charset=utf-8',
455
454
  * };
456
455
  * stream.respondWithFD(fd, headers);
457
456
  * stream.on('close', () => fs.closeSync(fd));
@@ -460,8 +459,8 @@ declare module "http2" {
460
459
  *
461
460
  * The optional `options.statCheck` function may be specified to give user code
462
461
  * an opportunity to set additional content headers based on the `fs.Stat` details
463
- * of the given fd. If the `statCheck` function is provided, the`http2stream.respondWithFD()` method will perform an `fs.fstat()` call to
464
- * collect details on the provided file descriptor.
462
+ * of the given fd. If the `statCheck` function is provided, the `http2stream.respondWithFD()` method will
463
+ * perform an `fs.fstat()` call to collect details on the provided file descriptor.
465
464
  *
466
465
  * The `offset` and `length` options may be used to limit the response to a
467
466
  * specific range subset. This can be used, for instance, to support HTTP Range
@@ -479,7 +478,8 @@ declare module "http2" {
479
478
  * header fields to the peer.
480
479
  *
481
480
  * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
482
- * close when the final `DATA` frame is transmitted. User code _must_ call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
481
+ * close when the final `DATA` frame is transmitted. User code _must_ call either `http2stream.sendTrailers()`
482
+ * or `http2stream.close()` to close the `Http2Stream`.
483
483
  *
484
484
  * ```js
485
485
  * const http2 = require('http2');
@@ -493,7 +493,7 @@ declare module "http2" {
493
493
  * const headers = {
494
494
  * 'content-length': stat.size,
495
495
  * 'last-modified': stat.mtime.toUTCString(),
496
- * 'content-type': 'text/plain; charset=utf-8'
496
+ * 'content-type': 'text/plain; charset=utf-8',
497
497
  * };
498
498
  * stream.respondWithFD(fd, headers, { waitForTrailers: true });
499
499
  * stream.on('wantTrailers', () => {
@@ -522,9 +522,9 @@ declare module "http2" {
522
522
  * an opportunity to set additional content headers based on the `fs.Stat` details
523
523
  * of the given file:
524
524
  *
525
- * If an error occurs while attempting to read the file data, the `Http2Stream`will be closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR`code. If the `onError` callback is
526
- * defined, then it will be called. Otherwise
527
- * the stream will be destroyed.
525
+ * If an error occurs while attempting to read the file data, the `Http2Stream` will be closed using an
526
+ * `RST_STREAM` frame using the standard `INTERNAL_ERROR` code.
527
+ * If the `onError` callback is defined, then it will be called. Otherwise, the stream will be destroyed.
528
528
  *
529
529
  * Example using a file path:
530
530
  *
@@ -547,7 +547,7 @@ declare module "http2" {
547
547
  * }
548
548
  * } catch (err) {
549
549
  * // Perform actual error handling.
550
- * console.log(err);
550
+ * console.error(err);
551
551
  * }
552
552
  * stream.end();
553
553
  * }
@@ -560,7 +560,7 @@ declare module "http2" {
560
560
  *
561
561
  * The `options.statCheck` function may also be used to cancel the send operation
562
562
  * by returning `false`. For instance, a conditional request may check the stat
563
- * results to determine if the file has been modified to return an appropriate`304` response:
563
+ * results to determine if the file has been modified to return an appropriate `304` response:
564
564
  *
565
565
  * ```js
566
566
  * const http2 = require('http2');
@@ -648,18 +648,18 @@ declare module "http2" {
648
648
  /**
649
649
  * Value will be `undefined` if the `Http2Session` is not yet connected to a
650
650
  * socket, `h2c` if the `Http2Session` is not connected to a `TLSSocket`, or
651
- * will return the value of the connected `TLSSocket`'s own `alpnProtocol`property.
651
+ * will return the value of the connected `TLSSocket`'s own `alpnProtocol` property.
652
652
  * @since v9.4.0
653
653
  */
654
654
  readonly alpnProtocol?: string | undefined;
655
655
  /**
656
- * Will be `true` if this `Http2Session` instance has been closed, otherwise`false`.
656
+ * Will be `true` if this `Http2Session` instance has been closed, otherwise `false`.
657
657
  * @since v9.4.0
658
658
  */
659
659
  readonly closed: boolean;
660
660
  /**
661
661
  * Will be `true` if this `Http2Session` instance is still connecting, will be set
662
- * to `false` before emitting `connect` event and/or calling the `http2.connect`callback.
662
+ * to `false` before emitting `connect` event and/or calling the `http2.connect` callback.
663
663
  * @since v10.0.0
664
664
  */
665
665
  readonly connecting: boolean;
@@ -678,7 +678,8 @@ declare module "http2" {
678
678
  */
679
679
  readonly encrypted?: boolean | undefined;
680
680
  /**
681
- * A prototype-less object describing the current local settings of this`Http2Session`. The local settings are local to _this_`Http2Session` instance.
681
+ * A prototype-less object describing the current local settings of this `Http2Session`.
682
+ * The local settings are local to _this_`Http2Session` instance.
682
683
  * @since v8.4.0
683
684
  */
684
685
  readonly localSettings: Settings;
@@ -693,12 +694,14 @@ declare module "http2" {
693
694
  readonly originSet?: string[] | undefined;
694
695
  /**
695
696
  * Indicates whether the `Http2Session` is currently waiting for acknowledgment of
696
- * a sent `SETTINGS` frame. Will be `true` after calling the`http2session.settings()` method. Will be `false` once all sent `SETTINGS`frames have been acknowledged.
697
+ * a sent `SETTINGS` frame. Will be `true` after calling the `http2session.settings()` method.
698
+ * Will be `false` once all sent `SETTINGS` frames have been acknowledged.
697
699
  * @since v8.4.0
698
700
  */
699
701
  readonly pendingSettingsAck: boolean;
700
702
  /**
701
- * A prototype-less object describing the current remote settings of this`Http2Session`. The remote settings are set by the _connected_ HTTP/2 peer.
703
+ * A prototype-less object describing the current remote settings of this`Http2Session`.
704
+ * The remote settings are set by the _connected_ HTTP/2 peer.
702
705
  * @since v8.4.0
703
706
  */
704
707
  readonly remoteSettings: Settings;
@@ -723,7 +726,7 @@ declare module "http2" {
723
726
  */
724
727
  readonly state: SessionState;
725
728
  /**
726
- * The `http2session.type` will be equal to`http2.constants.NGHTTP2_SESSION_SERVER` if this `Http2Session` instance is a
729
+ * The `http2session.type` will be equal to `http2.constants.NGHTTP2_SESSION_SERVER` if this `Http2Session` instance is a
727
730
  * server, and `http2.constants.NGHTTP2_SESSION_CLIENT` if the instance is a
728
731
  * client.
729
732
  * @since v8.4.0
@@ -740,11 +743,11 @@ declare module "http2" {
740
743
  */
741
744
  close(callback?: () => void): void;
742
745
  /**
743
- * Immediately terminates the `Http2Session` and the associated `net.Socket` or`tls.TLSSocket`.
746
+ * Immediately terminates the `Http2Session` and the associated `net.Socket` or `tls.TLSSocket`.
744
747
  *
745
- * Once destroyed, the `Http2Session` will emit the `'close'` event. If `error`is not undefined, an `'error'` event will be emitted immediately before the`'close'` event.
748
+ * Once destroyed, the `Http2Session` will emit the `'close'` event. If `error` is not undefined, an `'error'` event will be emitted immediately before the `'close'` event.
746
749
  *
747
- * If there are any remaining open `Http2Streams` associated with the`Http2Session`, those will also be destroyed.
750
+ * If there are any remaining open `Http2Streams` associated with the `Http2Session`, those will also be destroyed.
748
751
  * @since v8.4.0
749
752
  * @param error An `Error` object if the `Http2Session` is being destroyed due to an error.
750
753
  * @param code The HTTP/2 error code to send in the final `GOAWAY` frame. If unspecified, and `error` is not undefined, the default is `INTERNAL_ERROR`, otherwise defaults to `NO_ERROR`.
@@ -760,9 +763,9 @@ declare module "http2" {
760
763
  goaway(code?: number, lastStreamID?: number, opaqueData?: NodeJS.ArrayBufferView): void;
761
764
  /**
762
765
  * Sends a `PING` frame to the connected HTTP/2 peer. A `callback` function must
763
- * be provided. The method will return `true` if the `PING` was sent, `false`otherwise.
766
+ * be provided. The method will return `true` if the `PING` was sent, `false` otherwise.
764
767
  *
765
- * The maximum number of outstanding (unacknowledged) pings is determined by the`maxOutstandingPings` configuration option. The default maximum is 10.
768
+ * The maximum number of outstanding (unacknowledged) pings is determined by the `maxOutstandingPings` configuration option. The default maximum is 10.
766
769
  *
767
770
  * If provided, the `payload` must be a `Buffer`, `TypedArray`, or `DataView` containing 8 bytes of data that will be transmitted with the `PING` and
768
771
  * returned with the ping acknowledgment.
@@ -770,7 +773,7 @@ declare module "http2" {
770
773
  * The callback will be invoked with three arguments: an error argument that will
771
774
  * be `null` if the `PING` was successfully acknowledged, a `duration` argument
772
775
  * that reports the number of milliseconds elapsed since the ping was sent and the
773
- * acknowledgment was received, and a `Buffer` containing the 8-byte `PING`payload.
776
+ * acknowledgment was received, and a `Buffer` containing the 8-byte `PING` payload.
774
777
  *
775
778
  * ```js
776
779
  * session.ping(Buffer.from('abcdefgh'), (err, duration, payload) => {
@@ -792,7 +795,7 @@ declare module "http2" {
792
795
  callback: (err: Error | null, duration: number, payload: Buffer) => void,
793
796
  ): boolean;
794
797
  /**
795
- * Calls `ref()` on this `Http2Session`instance's underlying `net.Socket`.
798
+ * Calls `ref()` on this `Http2Session` instance's underlying `net.Socket`.
796
799
  * @since v9.4.0
797
800
  */
798
801
  ref(): void;
@@ -812,7 +815,7 @@ declare module "http2" {
812
815
  * session.setLocalWindowSize(expectedWindowSize);
813
816
  * });
814
817
  * ```
815
- * @since v15.3.0
818
+ * @since v15.3.0, v14.18.0
816
819
  */
817
820
  setLocalWindowSize(windowSize: number): void;
818
821
  /**
@@ -823,9 +826,9 @@ declare module "http2" {
823
826
  */
824
827
  setTimeout(msecs: number, callback?: () => void): void;
825
828
  /**
826
- * Updates the current local settings for this `Http2Session` and sends a new`SETTINGS` frame to the connected HTTP/2 peer.
829
+ * Updates the current local settings for this `Http2Session` and sends a new `SETTINGS` frame to the connected HTTP/2 peer.
827
830
  *
828
- * Once called, the `http2session.pendingSettingsAck` property will be `true`while the session is waiting for the remote peer to acknowledge the new
831
+ * Once called, the `http2session.pendingSettingsAck` property will be `true` while the session is waiting for the remote peer to acknowledge the new
829
832
  * settings.
830
833
  *
831
834
  * The new settings will not become effective until the `SETTINGS` acknowledgment
@@ -918,7 +921,7 @@ declare module "http2" {
918
921
  }
919
922
  export interface ClientHttp2Session extends Http2Session {
920
923
  /**
921
- * For HTTP/2 Client `Http2Session` instances only, the `http2session.request()`creates and returns an `Http2Stream` instance that can be used to send an
924
+ * For HTTP/2 Client `Http2Session` instances only, the `http2session.request()` creates and returns an `Http2Stream` instance that can be used to send an
922
925
  * HTTP/2 request to the connected server.
923
926
  *
924
927
  * This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`.
@@ -928,7 +931,7 @@ declare module "http2" {
928
931
  * const clientSession = http2.connect('https://localhost:1234');
929
932
  * const {
930
933
  * HTTP2_HEADER_PATH,
931
- * HTTP2_HEADER_STATUS
934
+ * HTTP2_HEADER_STATUS,
932
935
  * } = http2.constants;
933
936
  *
934
937
  * const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' });
@@ -1044,8 +1047,19 @@ declare module "http2" {
1044
1047
  export interface AlternativeServiceOptions {
1045
1048
  origin: number | string | url.URL;
1046
1049
  }
1047
- export interface ServerHttp2Session extends Http2Session {
1048
- readonly server: Http2Server | Http2SecureServer;
1050
+ export interface ServerHttp2Session<
1051
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1052
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1053
+ InstanceType<Http1Request>
1054
+ >,
1055
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1056
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1057
+ InstanceType<Http2Request>
1058
+ >,
1059
+ > extends Http2Session {
1060
+ readonly server:
1061
+ | Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>
1062
+ | Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
1049
1063
  /**
1050
1064
  * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.
1051
1065
  *
@@ -1104,7 +1118,7 @@ declare module "http2" {
1104
1118
  * ```
1105
1119
  *
1106
1120
  * When a string is passed as an `origin`, it will be parsed as a URL and the
1107
- * origin will be derived. For instance, the origin for the HTTP URL`'https://example.org/foo/bar'` is the ASCII string`'https://example.org'`. An error will be thrown if either the given
1121
+ * origin will be derived. For instance, the origin for the HTTP URL `'https://example.org/foo/bar'` is the ASCII string` 'https://example.org'`. An error will be thrown if either the given
1108
1122
  * string
1109
1123
  * cannot be parsed as a URL or if a valid origin cannot be derived.
1110
1124
  *
@@ -1140,17 +1154,30 @@ declare module "http2" {
1140
1154
  ): void;
1141
1155
  addListener(
1142
1156
  event: "connect",
1143
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1157
+ listener: (
1158
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1159
+ socket: net.Socket | tls.TLSSocket,
1160
+ ) => void,
1144
1161
  ): this;
1145
1162
  addListener(
1146
1163
  event: "stream",
1147
1164
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1148
1165
  ): this;
1149
1166
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1150
- emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
1167
+ emit(
1168
+ event: "connect",
1169
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1170
+ socket: net.Socket | tls.TLSSocket,
1171
+ ): boolean;
1151
1172
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1152
1173
  emit(event: string | symbol, ...args: any[]): boolean;
1153
- on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
1174
+ on(
1175
+ event: "connect",
1176
+ listener: (
1177
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1178
+ socket: net.Socket | tls.TLSSocket,
1179
+ ) => void,
1180
+ ): this;
1154
1181
  on(
1155
1182
  event: "stream",
1156
1183
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1158,7 +1185,10 @@ declare module "http2" {
1158
1185
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1159
1186
  once(
1160
1187
  event: "connect",
1161
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1188
+ listener: (
1189
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1190
+ socket: net.Socket | tls.TLSSocket,
1191
+ ) => void,
1162
1192
  ): this;
1163
1193
  once(
1164
1194
  event: "stream",
@@ -1167,7 +1197,10 @@ declare module "http2" {
1167
1197
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1168
1198
  prependListener(
1169
1199
  event: "connect",
1170
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1200
+ listener: (
1201
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1202
+ socket: net.Socket | tls.TLSSocket,
1203
+ ) => void,
1171
1204
  ): this;
1172
1205
  prependListener(
1173
1206
  event: "stream",
@@ -1176,7 +1209,10 @@ declare module "http2" {
1176
1209
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1177
1210
  prependOnceListener(
1178
1211
  event: "connect",
1179
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1212
+ listener: (
1213
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1214
+ socket: net.Socket | tls.TLSSocket,
1215
+ ) => void,
1180
1216
  ): this;
1181
1217
  prependOnceListener(
1182
1218
  event: "stream",
@@ -1208,16 +1244,52 @@ declare module "http2" {
1208
1244
  createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined;
1209
1245
  protocol?: "http:" | "https:" | undefined;
1210
1246
  }
1211
- export interface ServerSessionOptions extends SessionOptions {
1212
- Http1IncomingMessage?: typeof IncomingMessage | undefined;
1213
- Http1ServerResponse?: typeof ServerResponse | undefined;
1214
- Http2ServerRequest?: typeof Http2ServerRequest | undefined;
1215
- Http2ServerResponse?: typeof Http2ServerResponse | undefined;
1247
+ export interface ServerSessionOptions<
1248
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1249
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1250
+ InstanceType<Http1Request>
1251
+ >,
1252
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1253
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1254
+ InstanceType<Http2Request>
1255
+ >,
1256
+ > extends SessionOptions {
1257
+ Http1IncomingMessage?: Http1Request | undefined;
1258
+ Http1ServerResponse?: Http1Response | undefined;
1259
+ Http2ServerRequest?: Http2Request | undefined;
1260
+ Http2ServerResponse?: Http2Response | undefined;
1216
1261
  }
1217
1262
  export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions {}
1218
- export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions {}
1219
- export interface ServerOptions extends ServerSessionOptions {}
1220
- export interface SecureServerOptions extends SecureServerSessionOptions {
1263
+ export interface SecureServerSessionOptions<
1264
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1265
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1266
+ InstanceType<Http1Request>
1267
+ >,
1268
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1269
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1270
+ InstanceType<Http2Request>
1271
+ >,
1272
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response>, tls.TlsOptions {}
1273
+ export interface ServerOptions<
1274
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1275
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1276
+ InstanceType<Http1Request>
1277
+ >,
1278
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1279
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1280
+ InstanceType<Http2Request>
1281
+ >,
1282
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {}
1283
+ export interface SecureServerOptions<
1284
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1285
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1286
+ InstanceType<Http1Request>
1287
+ >,
1288
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1289
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1290
+ InstanceType<Http2Request>
1291
+ >,
1292
+ > extends SecureServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {
1221
1293
  allowHTTP1?: boolean | undefined;
1222
1294
  origins?: string[] | undefined;
1223
1295
  }
@@ -1229,16 +1301,28 @@ declare module "http2" {
1229
1301
  */
1230
1302
  updateSettings(settings: Settings): void;
1231
1303
  }
1232
- export interface Http2Server extends net.Server, HTTP2ServerCommon {
1304
+ export interface Http2Server<
1305
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1306
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1307
+ InstanceType<Http1Request>
1308
+ >,
1309
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1310
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1311
+ InstanceType<Http2Request>
1312
+ >,
1313
+ > extends net.Server, HTTP2ServerCommon {
1233
1314
  addListener(
1234
1315
  event: "checkContinue",
1235
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1316
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1236
1317
  ): this;
1237
1318
  addListener(
1238
1319
  event: "request",
1239
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1320
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1321
+ ): this;
1322
+ addListener(
1323
+ event: "session",
1324
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1240
1325
  ): this;
1241
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1242
1326
  addListener(event: "sessionError", listener: (err: Error) => void): this;
1243
1327
  addListener(
1244
1328
  event: "stream",
@@ -1246,19 +1330,32 @@ declare module "http2" {
1246
1330
  ): this;
1247
1331
  addListener(event: "timeout", listener: () => void): this;
1248
1332
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1249
- emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1250
- emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1251
- emit(event: "session", session: ServerHttp2Session): boolean;
1333
+ emit(
1334
+ event: "checkContinue",
1335
+ request: InstanceType<Http2Request>,
1336
+ response: InstanceType<Http2Response>,
1337
+ ): boolean;
1338
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1339
+ emit(
1340
+ event: "session",
1341
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1342
+ ): boolean;
1252
1343
  emit(event: "sessionError", err: Error): boolean;
1253
1344
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1254
1345
  emit(event: "timeout"): boolean;
1255
1346
  emit(event: string | symbol, ...args: any[]): boolean;
1256
1347
  on(
1257
1348
  event: "checkContinue",
1258
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1349
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1350
+ ): this;
1351
+ on(
1352
+ event: "request",
1353
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1354
+ ): this;
1355
+ on(
1356
+ event: "session",
1357
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1259
1358
  ): this;
1260
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1261
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1262
1359
  on(event: "sessionError", listener: (err: Error) => void): this;
1263
1360
  on(
1264
1361
  event: "stream",
@@ -1268,10 +1365,16 @@ declare module "http2" {
1268
1365
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1269
1366
  once(
1270
1367
  event: "checkContinue",
1271
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1368
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1369
+ ): this;
1370
+ once(
1371
+ event: "request",
1372
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1373
+ ): this;
1374
+ once(
1375
+ event: "session",
1376
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1272
1377
  ): this;
1273
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1274
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1275
1378
  once(event: "sessionError", listener: (err: Error) => void): this;
1276
1379
  once(
1277
1380
  event: "stream",
@@ -1281,13 +1384,16 @@ declare module "http2" {
1281
1384
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1282
1385
  prependListener(
1283
1386
  event: "checkContinue",
1284
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1387
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1285
1388
  ): this;
1286
1389
  prependListener(
1287
1390
  event: "request",
1288
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1391
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1392
+ ): this;
1393
+ prependListener(
1394
+ event: "session",
1395
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1289
1396
  ): this;
1290
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1291
1397
  prependListener(event: "sessionError", listener: (err: Error) => void): this;
1292
1398
  prependListener(
1293
1399
  event: "stream",
@@ -1297,13 +1403,16 @@ declare module "http2" {
1297
1403
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1298
1404
  prependOnceListener(
1299
1405
  event: "checkContinue",
1300
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1406
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1301
1407
  ): this;
1302
1408
  prependOnceListener(
1303
1409
  event: "request",
1304
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1410
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1411
+ ): this;
1412
+ prependOnceListener(
1413
+ event: "session",
1414
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1305
1415
  ): this;
1306
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1307
1416
  prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1308
1417
  prependOnceListener(
1309
1418
  event: "stream",
@@ -1312,16 +1421,28 @@ declare module "http2" {
1312
1421
  prependOnceListener(event: "timeout", listener: () => void): this;
1313
1422
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1314
1423
  }
1315
- export interface Http2SecureServer extends tls.Server, HTTP2ServerCommon {
1424
+ export interface Http2SecureServer<
1425
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1426
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1427
+ InstanceType<Http1Request>
1428
+ >,
1429
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1430
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1431
+ InstanceType<Http2Request>
1432
+ >,
1433
+ > extends tls.Server, HTTP2ServerCommon {
1316
1434
  addListener(
1317
1435
  event: "checkContinue",
1318
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1436
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1319
1437
  ): this;
1320
1438
  addListener(
1321
1439
  event: "request",
1322
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1440
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1441
+ ): this;
1442
+ addListener(
1443
+ event: "session",
1444
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1323
1445
  ): this;
1324
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1325
1446
  addListener(event: "sessionError", listener: (err: Error) => void): this;
1326
1447
  addListener(
1327
1448
  event: "stream",
@@ -1330,9 +1451,16 @@ declare module "http2" {
1330
1451
  addListener(event: "timeout", listener: () => void): this;
1331
1452
  addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1332
1453
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1333
- emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1334
- emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1335
- emit(event: "session", session: ServerHttp2Session): boolean;
1454
+ emit(
1455
+ event: "checkContinue",
1456
+ request: InstanceType<Http2Request>,
1457
+ response: InstanceType<Http2Response>,
1458
+ ): boolean;
1459
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1460
+ emit(
1461
+ event: "session",
1462
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1463
+ ): boolean;
1336
1464
  emit(event: "sessionError", err: Error): boolean;
1337
1465
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1338
1466
  emit(event: "timeout"): boolean;
@@ -1340,10 +1468,16 @@ declare module "http2" {
1340
1468
  emit(event: string | symbol, ...args: any[]): boolean;
1341
1469
  on(
1342
1470
  event: "checkContinue",
1343
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1471
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1472
+ ): this;
1473
+ on(
1474
+ event: "request",
1475
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1476
+ ): this;
1477
+ on(
1478
+ event: "session",
1479
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1344
1480
  ): this;
1345
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1346
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1347
1481
  on(event: "sessionError", listener: (err: Error) => void): this;
1348
1482
  on(
1349
1483
  event: "stream",
@@ -1354,10 +1488,16 @@ declare module "http2" {
1354
1488
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1355
1489
  once(
1356
1490
  event: "checkContinue",
1357
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1491
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1492
+ ): this;
1493
+ once(
1494
+ event: "request",
1495
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1496
+ ): this;
1497
+ once(
1498
+ event: "session",
1499
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1358
1500
  ): this;
1359
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1360
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1361
1501
  once(event: "sessionError", listener: (err: Error) => void): this;
1362
1502
  once(
1363
1503
  event: "stream",
@@ -1368,13 +1508,16 @@ declare module "http2" {
1368
1508
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1369
1509
  prependListener(
1370
1510
  event: "checkContinue",
1371
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1511
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1372
1512
  ): this;
1373
1513
  prependListener(
1374
1514
  event: "request",
1375
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1515
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1516
+ ): this;
1517
+ prependListener(
1518
+ event: "session",
1519
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1376
1520
  ): this;
1377
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1378
1521
  prependListener(event: "sessionError", listener: (err: Error) => void): this;
1379
1522
  prependListener(
1380
1523
  event: "stream",
@@ -1385,13 +1528,16 @@ declare module "http2" {
1385
1528
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1386
1529
  prependOnceListener(
1387
1530
  event: "checkContinue",
1388
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1531
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1389
1532
  ): this;
1390
1533
  prependOnceListener(
1391
1534
  event: "request",
1392
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1535
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1536
+ ): this;
1537
+ prependOnceListener(
1538
+ event: "session",
1539
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1393
1540
  ): this;
1394
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1395
1541
  prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1396
1542
  prependOnceListener(
1397
1543
  event: "stream",
@@ -1422,7 +1568,7 @@ declare module "http2" {
1422
1568
  readonly aborted: boolean;
1423
1569
  /**
1424
1570
  * The request authority pseudo header field. Because HTTP/2 allows requests
1425
- * to set either `:authority` or `host`, this value is derived from`req.headers[':authority']` if present. Otherwise, it is derived from`req.headers['host']`.
1571
+ * to set either `:authority` or `host`, this value is derived from `req.headers[':authority']` if present. Otherwise, it is derived from `req.headers['host']`.
1426
1572
  * @since v8.4.0
1427
1573
  */
1428
1574
  readonly authority: string;
@@ -1469,9 +1615,9 @@ declare module "http2" {
1469
1615
  readonly headers: IncomingHttpHeaders;
1470
1616
  /**
1471
1617
  * In case of server request, the HTTP version sent by the client. In the case of
1472
- * client response, the HTTP version of the connected-to server. Returns`'2.0'`.
1618
+ * client response, the HTTP version of the connected-to server. Returns `'2.0'`.
1473
1619
  *
1474
- * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
1620
+ * Also `message.httpVersionMajor` is the first integer and `message.httpVersionMinor` is the second.
1475
1621
  * @since v8.4.0
1476
1622
  */
1477
1623
  readonly httpVersion: string;
@@ -1526,11 +1672,11 @@ declare module "http2" {
1526
1672
  * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1527
1673
  * set on `request.stream`.
1528
1674
  *
1529
- * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`request.stream`.
1675
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on `request.stream`.
1530
1676
  *
1531
1677
  * `setTimeout` method will be called on `request.stream.session`.
1532
1678
  *
1533
- * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1679
+ * `pause`, `read`, `resume`, and `write` will throw an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1534
1680
  * more information.
1535
1681
  *
1536
1682
  * All other interactions will be routed directly to the socket. With TLS support,
@@ -1593,7 +1739,7 @@ declare module "http2" {
1593
1739
  * the response object.
1594
1740
  *
1595
1741
  * If no `'timeout'` listener is added to the request, the response, or
1596
- * the server, then `Http2Stream` s are destroyed when they time out. If a
1742
+ * the server, then `Http2Stream`s are destroyed when they time out. If a
1597
1743
  * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly.
1598
1744
  * @since v8.4.0
1599
1745
  */
@@ -1647,7 +1793,7 @@ declare module "http2" {
1647
1793
  * passed as the second parameter to the `'request'` event.
1648
1794
  * @since v8.4.0
1649
1795
  */
1650
- export class Http2ServerResponse extends stream.Writable {
1796
+ export class Http2ServerResponse<Request extends Http2ServerRequest = Http2ServerRequest> extends stream.Writable {
1651
1797
  constructor(stream: ServerHttp2Stream);
1652
1798
  /**
1653
1799
  * See `response.socket`.
@@ -1668,10 +1814,10 @@ declare module "http2" {
1668
1814
  */
1669
1815
  readonly headersSent: boolean;
1670
1816
  /**
1671
- * A reference to the original HTTP2 request object.
1817
+ * A reference to the original HTTP2 `request` object.
1672
1818
  * @since v15.7.0
1673
1819
  */
1674
- readonly req: Http2ServerRequest;
1820
+ readonly req: Request;
1675
1821
  /**
1676
1822
  * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but
1677
1823
  * applies getters, setters, and methods based on HTTP/2 logic.
@@ -1679,11 +1825,11 @@ declare module "http2" {
1679
1825
  * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1680
1826
  * set on `response.stream`.
1681
1827
  *
1682
- * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`response.stream`.
1828
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on `response.stream`.
1683
1829
  *
1684
1830
  * `setTimeout` method will be called on `response.stream.session`.
1685
1831
  *
1686
- * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1832
+ * `pause`, `read`, `resume`, and `write` will throw an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1687
1833
  * more information.
1688
1834
  *
1689
1835
  * All other interactions will be routed directly to the socket.
@@ -1787,7 +1933,7 @@ declare module "http2" {
1787
1933
  * header names and the values are the respective header values. All header names
1788
1934
  * are lowercase.
1789
1935
  *
1790
- * The object returned by the `response.getHeaders()` method _does not_prototypically inherit from the JavaScript `Object`. This means that typical`Object` methods such as `obj.toString()`,
1936
+ * The object returned by the `response.getHeaders()` method _does not_ prototypically inherit from the JavaScript `Object`. This means that typical `Object` methods such as `obj.toString()`,
1791
1937
  * `obj.hasOwnProperty()`, and others
1792
1938
  * are not defined and _will not work_.
1793
1939
  *
@@ -1861,7 +2007,7 @@ declare module "http2" {
1861
2007
  *
1862
2008
  * If no `'timeout'` listener is added to the request, the response, or
1863
2009
  * the server, then `Http2Stream` s are destroyed when they time out. If a
1864
- * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly.
2010
+ * handler is assigned to the request, the response, or the server's `'timeout'` events, timed out sockets must be handled explicitly.
1865
2011
  * @since v8.4.0
1866
2012
  */
1867
2013
  setTimeout(msecs: number, callback?: () => void): void;
@@ -1872,8 +2018,8 @@ declare module "http2" {
1872
2018
  * This sends a chunk of the response body. This method may
1873
2019
  * be called multiple times to provide successive parts of the body.
1874
2020
  *
1875
- * In the `http` module, the response body is omitted when the
1876
- * request is a HEAD request. Similarly, the `204` and `304` responses_must not_ include a message body.
2021
+ * In the `node:http` module, the response body is omitted when the
2022
+ * request is a HEAD request. Similarly, the `204` and `304` responses _must not_ include a message body.
1877
2023
  *
1878
2024
  * `chunk` can be a string or a buffer. If `chunk` is a string,
1879
2025
  * the second parameter specifies how to encode it into a byte stream.
@@ -1923,7 +2069,7 @@ declare module "http2" {
1923
2069
  * `Content-Length` is given in bytes not characters. The`Buffer.byteLength()` API may be used to determine the number of bytes in a
1924
2070
  * given encoding. On outbound messages, Node.js does not check if Content-Length
1925
2071
  * and the length of the body being transmitted are equal or not. However, when
1926
- * receiving messages, Node.js will automatically reject messages when the`Content-Length` does not match the actual payload size.
2072
+ * receiving messages, Node.js will automatically reject messages when the `Content-Length` does not match the actual payload size.
1927
2073
  *
1928
2074
  * This method may be called at most one time on a message before `response.end()` is called.
1929
2075
  *
@@ -2229,7 +2375,7 @@ declare module "http2" {
2229
2375
  */
2230
2376
  export const sensitiveHeaders: symbol;
2231
2377
  /**
2232
- * Returns an object containing the default settings for an `Http2Session`instance. This method returns a new object instance every time it is called
2378
+ * Returns an object containing the default settings for an `Http2Session` instance. This method returns a new object instance every time it is called
2233
2379
  * so instances returned may be safely modified for use.
2234
2380
  * @since v8.4.0
2235
2381
  */
@@ -2258,7 +2404,7 @@ declare module "http2" {
2258
2404
  */
2259
2405
  export function getUnpackedSettings(buf: Uint8Array): Settings;
2260
2406
  /**
2261
- * Returns a `net.Server` instance that creates and manages `Http2Session`instances.
2407
+ * Returns a `net.Server` instance that creates and manages `Http2Session` instances.
2262
2408
  *
2263
2409
  * Since there are no browsers known that support [unencrypted HTTP/2](https://http2.github.io/faq/#does-http2-require-encryption), the use of {@link createSecureServer} is necessary when
2264
2410
  * communicating
@@ -2276,12 +2422,12 @@ declare module "http2" {
2276
2422
  * server.on('stream', (stream, headers) => {
2277
2423
  * stream.respond({
2278
2424
  * 'content-type': 'text/html; charset=utf-8',
2279
- * ':status': 200
2425
+ * ':status': 200,
2280
2426
  * });
2281
2427
  * stream.end('<h1>Hello World</h1>');
2282
2428
  * });
2283
2429
  *
2284
- * server.listen(80);
2430
+ * server.listen(8000);
2285
2431
  * ```
2286
2432
  * @since v8.4.0
2287
2433
  * @param onRequestHandler See `Compatibility API`
@@ -2289,12 +2435,21 @@ declare module "http2" {
2289
2435
  export function createServer(
2290
2436
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2291
2437
  ): Http2Server;
2292
- export function createServer(
2293
- options: ServerOptions,
2294
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2295
- ): Http2Server;
2438
+ export function createServer<
2439
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2440
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
2441
+ InstanceType<Http1Request>
2442
+ >,
2443
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2444
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
2445
+ InstanceType<Http2Request>
2446
+ >,
2447
+ >(
2448
+ options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2449
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2450
+ ): Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>;
2296
2451
  /**
2297
- * Returns a `tls.Server` instance that creates and manages `Http2Session`instances.
2452
+ * Returns a `tls.Server` instance that creates and manages `Http2Session` instances.
2298
2453
  *
2299
2454
  * ```js
2300
2455
  * const http2 = require('http2');
@@ -2302,7 +2457,7 @@ declare module "http2" {
2302
2457
  *
2303
2458
  * const options = {
2304
2459
  * key: fs.readFileSync('server-key.pem'),
2305
- * cert: fs.readFileSync('server-cert.pem')
2460
+ * cert: fs.readFileSync('server-cert.pem'),
2306
2461
  * };
2307
2462
  *
2308
2463
  * // Create a secure HTTP/2 server
@@ -2311,12 +2466,12 @@ declare module "http2" {
2311
2466
  * server.on('stream', (stream, headers) => {
2312
2467
  * stream.respond({
2313
2468
  * 'content-type': 'text/html; charset=utf-8',
2314
- * ':status': 200
2469
+ * ':status': 200,
2315
2470
  * });
2316
2471
  * stream.end('<h1>Hello World</h1>');
2317
2472
  * });
2318
2473
  *
2319
- * server.listen(80);
2474
+ * server.listen(8443);
2320
2475
  * ```
2321
2476
  * @since v8.4.0
2322
2477
  * @param onRequestHandler See `Compatibility API`
@@ -2324,10 +2479,19 @@ declare module "http2" {
2324
2479
  export function createSecureServer(
2325
2480
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2326
2481
  ): Http2SecureServer;
2327
- export function createSecureServer(
2328
- options: SecureServerOptions,
2329
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2330
- ): Http2SecureServer;
2482
+ export function createSecureServer<
2483
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2484
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
2485
+ InstanceType<Http1Request>
2486
+ >,
2487
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2488
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
2489
+ InstanceType<Http2Request>
2490
+ >,
2491
+ >(
2492
+ options: SecureServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2493
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2494
+ ): Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
2331
2495
  /**
2332
2496
  * Returns a `ClientHttp2Session` instance.
2333
2497
  *
node v16.18/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(
@@ -109,19 +115,19 @@ declare module "https" {
109
115
  emit(
110
116
  event: "checkContinue",
111
117
  req: InstanceType<Request>,
112
- res: InstanceType<Response> & { req: InstanceType<Request> },
118
+ res: InstanceType<Response>,
113
119
  ): boolean;
114
120
  emit(
115
121
  event: "checkExpectation",
116
122
  req: InstanceType<Request>,
117
- res: InstanceType<Response> & { req: InstanceType<Request> },
123
+ res: InstanceType<Response>,
118
124
  ): boolean;
119
125
  emit(event: "clientError", err: Error, socket: Duplex): boolean;
120
126
  emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
121
127
  emit(
122
128
  event: "request",
123
129
  req: InstanceType<Request>,
124
- res: InstanceType<Response> & { req: InstanceType<Request> },
130
+ res: InstanceType<Response>,
125
131
  ): boolean;
126
132
  emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
127
133
  on(event: string, listener: (...args: any[]) => void): this;
@@ -296,11 +302,15 @@ declare module "https" {
296
302
  */
297
303
  function createServer<
298
304
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
299
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
305
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
306
+ InstanceType<Request>
307
+ >,
300
308
  >(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
301
309
  function createServer<
302
310
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
303
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
311
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
312
+ InstanceType<Request>
313
+ >,
304
314
  >(
305
315
  options: ServerOptions<Request, Response>,
306
316
  requestListener?: http.RequestListener<Request, Response>,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "16.18.105",
3
+ "version": "16.18.107",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -210,6 +210,6 @@
210
210
  },
211
211
  "scripts": {},
212
212
  "dependencies": {},
213
- "typesPublisherContentHash": "874d7cf34debf8ade03f10fb7f16085564a36a3b023ae4a14d539655bc0dbfb4",
213
+ "typesPublisherContentHash": "2e43ad1a49e4e03c340b7cddb756224a8aa3814562090f931c92dd3647a13e23",
214
214
  "typeScriptVersion": "4.8"
215
215
  }