@types/node 16.18.108 → 16.18.109

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: Wed, 04 Sep 2024 21:35:57 GMT
11
+ * Last updated: Wed, 25 Sep 2024 00:29:50 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
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,
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,
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,
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,
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,
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,15 @@ 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
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1054
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1055
+ > extends Http2Session {
1056
+ readonly server:
1057
+ | Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>
1058
+ | Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
1049
1059
  /**
1050
1060
  * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.
1051
1061
  *
@@ -1104,7 +1114,7 @@ declare module "http2" {
1104
1114
  * ```
1105
1115
  *
1106
1116
  * 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
1117
+ * 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
1118
  * string
1109
1119
  * cannot be parsed as a URL or if a valid origin cannot be derived.
1110
1120
  *
@@ -1140,17 +1150,30 @@ declare module "http2" {
1140
1150
  ): void;
1141
1151
  addListener(
1142
1152
  event: "connect",
1143
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1153
+ listener: (
1154
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1155
+ socket: net.Socket | tls.TLSSocket,
1156
+ ) => void,
1144
1157
  ): this;
1145
1158
  addListener(
1146
1159
  event: "stream",
1147
1160
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1148
1161
  ): this;
1149
1162
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1150
- emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
1163
+ emit(
1164
+ event: "connect",
1165
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1166
+ socket: net.Socket | tls.TLSSocket,
1167
+ ): boolean;
1151
1168
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1152
1169
  emit(event: string | symbol, ...args: any[]): boolean;
1153
- on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
1170
+ on(
1171
+ event: "connect",
1172
+ listener: (
1173
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1174
+ socket: net.Socket | tls.TLSSocket,
1175
+ ) => void,
1176
+ ): this;
1154
1177
  on(
1155
1178
  event: "stream",
1156
1179
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1158,7 +1181,10 @@ declare module "http2" {
1158
1181
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1159
1182
  once(
1160
1183
  event: "connect",
1161
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1184
+ listener: (
1185
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1186
+ socket: net.Socket | tls.TLSSocket,
1187
+ ) => void,
1162
1188
  ): this;
1163
1189
  once(
1164
1190
  event: "stream",
@@ -1167,7 +1193,10 @@ declare module "http2" {
1167
1193
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1168
1194
  prependListener(
1169
1195
  event: "connect",
1170
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1196
+ listener: (
1197
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1198
+ socket: net.Socket | tls.TLSSocket,
1199
+ ) => void,
1171
1200
  ): this;
1172
1201
  prependListener(
1173
1202
  event: "stream",
@@ -1176,7 +1205,10 @@ declare module "http2" {
1176
1205
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1177
1206
  prependOnceListener(
1178
1207
  event: "connect",
1179
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1208
+ listener: (
1209
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1210
+ socket: net.Socket | tls.TLSSocket,
1211
+ ) => void,
1180
1212
  ): this;
1181
1213
  prependOnceListener(
1182
1214
  event: "stream",
@@ -1208,16 +1240,36 @@ declare module "http2" {
1208
1240
  createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined;
1209
1241
  protocol?: "http:" | "https:" | undefined;
1210
1242
  }
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;
1243
+ export interface ServerSessionOptions<
1244
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1245
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1246
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1247
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1248
+ > extends SessionOptions {
1249
+ Http1IncomingMessage?: Http1Request | undefined;
1250
+ Http1ServerResponse?: Http1Response | undefined;
1251
+ Http2ServerRequest?: Http2Request | undefined;
1252
+ Http2ServerResponse?: Http2Response | undefined;
1216
1253
  }
1217
1254
  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 {
1255
+ export interface SecureServerSessionOptions<
1256
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1257
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1258
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1259
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1260
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response>, tls.TlsOptions {}
1261
+ export interface ServerOptions<
1262
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1263
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1264
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1265
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1266
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {}
1267
+ export interface SecureServerOptions<
1268
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1269
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1270
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1271
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1272
+ > extends SecureServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {
1221
1273
  allowHTTP1?: boolean | undefined;
1222
1274
  origins?: string[] | undefined;
1223
1275
  }
@@ -1229,16 +1281,24 @@ declare module "http2" {
1229
1281
  */
1230
1282
  updateSettings(settings: Settings): void;
1231
1283
  }
1232
- export interface Http2Server extends net.Server, HTTP2ServerCommon {
1284
+ export interface Http2Server<
1285
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1286
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1287
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1288
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1289
+ > extends net.Server, HTTP2ServerCommon {
1233
1290
  addListener(
1234
1291
  event: "checkContinue",
1235
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1292
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1236
1293
  ): this;
1237
1294
  addListener(
1238
1295
  event: "request",
1239
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1296
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1297
+ ): this;
1298
+ addListener(
1299
+ event: "session",
1300
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1240
1301
  ): this;
1241
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1242
1302
  addListener(event: "sessionError", listener: (err: Error) => void): this;
1243
1303
  addListener(
1244
1304
  event: "stream",
@@ -1246,19 +1306,32 @@ declare module "http2" {
1246
1306
  ): this;
1247
1307
  addListener(event: "timeout", listener: () => void): this;
1248
1308
  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;
1309
+ emit(
1310
+ event: "checkContinue",
1311
+ request: InstanceType<Http2Request>,
1312
+ response: InstanceType<Http2Response>,
1313
+ ): boolean;
1314
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1315
+ emit(
1316
+ event: "session",
1317
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1318
+ ): boolean;
1252
1319
  emit(event: "sessionError", err: Error): boolean;
1253
1320
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1254
1321
  emit(event: "timeout"): boolean;
1255
1322
  emit(event: string | symbol, ...args: any[]): boolean;
1256
1323
  on(
1257
1324
  event: "checkContinue",
1258
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1325
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1326
+ ): this;
1327
+ on(
1328
+ event: "request",
1329
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1330
+ ): this;
1331
+ on(
1332
+ event: "session",
1333
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1259
1334
  ): this;
1260
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1261
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1262
1335
  on(event: "sessionError", listener: (err: Error) => void): this;
1263
1336
  on(
1264
1337
  event: "stream",
@@ -1268,10 +1341,16 @@ declare module "http2" {
1268
1341
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1269
1342
  once(
1270
1343
  event: "checkContinue",
1271
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1344
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1345
+ ): this;
1346
+ once(
1347
+ event: "request",
1348
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1349
+ ): this;
1350
+ once(
1351
+ event: "session",
1352
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1272
1353
  ): this;
1273
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1274
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1275
1354
  once(event: "sessionError", listener: (err: Error) => void): this;
1276
1355
  once(
1277
1356
  event: "stream",
@@ -1281,13 +1360,16 @@ declare module "http2" {
1281
1360
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1282
1361
  prependListener(
1283
1362
  event: "checkContinue",
1284
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1363
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1285
1364
  ): this;
1286
1365
  prependListener(
1287
1366
  event: "request",
1288
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1367
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1368
+ ): this;
1369
+ prependListener(
1370
+ event: "session",
1371
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1289
1372
  ): this;
1290
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1291
1373
  prependListener(event: "sessionError", listener: (err: Error) => void): this;
1292
1374
  prependListener(
1293
1375
  event: "stream",
@@ -1297,13 +1379,16 @@ declare module "http2" {
1297
1379
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1298
1380
  prependOnceListener(
1299
1381
  event: "checkContinue",
1300
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1382
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1301
1383
  ): this;
1302
1384
  prependOnceListener(
1303
1385
  event: "request",
1304
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1386
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1387
+ ): this;
1388
+ prependOnceListener(
1389
+ event: "session",
1390
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1305
1391
  ): this;
1306
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1307
1392
  prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1308
1393
  prependOnceListener(
1309
1394
  event: "stream",
@@ -1312,16 +1397,24 @@ declare module "http2" {
1312
1397
  prependOnceListener(event: "timeout", listener: () => void): this;
1313
1398
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1314
1399
  }
1315
- export interface Http2SecureServer extends tls.Server, HTTP2ServerCommon {
1400
+ export interface Http2SecureServer<
1401
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1402
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1403
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1404
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1405
+ > extends tls.Server, HTTP2ServerCommon {
1316
1406
  addListener(
1317
1407
  event: "checkContinue",
1318
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1408
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1319
1409
  ): this;
1320
1410
  addListener(
1321
1411
  event: "request",
1322
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1412
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1413
+ ): this;
1414
+ addListener(
1415
+ event: "session",
1416
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1323
1417
  ): this;
1324
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1325
1418
  addListener(event: "sessionError", listener: (err: Error) => void): this;
1326
1419
  addListener(
1327
1420
  event: "stream",
@@ -1330,9 +1423,16 @@ declare module "http2" {
1330
1423
  addListener(event: "timeout", listener: () => void): this;
1331
1424
  addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1332
1425
  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;
1426
+ emit(
1427
+ event: "checkContinue",
1428
+ request: InstanceType<Http2Request>,
1429
+ response: InstanceType<Http2Response>,
1430
+ ): boolean;
1431
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1432
+ emit(
1433
+ event: "session",
1434
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1435
+ ): boolean;
1336
1436
  emit(event: "sessionError", err: Error): boolean;
1337
1437
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1338
1438
  emit(event: "timeout"): boolean;
@@ -1340,10 +1440,16 @@ declare module "http2" {
1340
1440
  emit(event: string | symbol, ...args: any[]): boolean;
1341
1441
  on(
1342
1442
  event: "checkContinue",
1343
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1443
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1444
+ ): this;
1445
+ on(
1446
+ event: "request",
1447
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1448
+ ): this;
1449
+ on(
1450
+ event: "session",
1451
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1344
1452
  ): this;
1345
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1346
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1347
1453
  on(event: "sessionError", listener: (err: Error) => void): this;
1348
1454
  on(
1349
1455
  event: "stream",
@@ -1354,10 +1460,16 @@ declare module "http2" {
1354
1460
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1355
1461
  once(
1356
1462
  event: "checkContinue",
1357
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1463
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1464
+ ): this;
1465
+ once(
1466
+ event: "request",
1467
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1468
+ ): this;
1469
+ once(
1470
+ event: "session",
1471
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1358
1472
  ): this;
1359
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1360
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1361
1473
  once(event: "sessionError", listener: (err: Error) => void): this;
1362
1474
  once(
1363
1475
  event: "stream",
@@ -1368,13 +1480,16 @@ declare module "http2" {
1368
1480
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1369
1481
  prependListener(
1370
1482
  event: "checkContinue",
1371
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1483
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1372
1484
  ): this;
1373
1485
  prependListener(
1374
1486
  event: "request",
1375
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1487
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1488
+ ): this;
1489
+ prependListener(
1490
+ event: "session",
1491
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1376
1492
  ): this;
1377
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1378
1493
  prependListener(event: "sessionError", listener: (err: Error) => void): this;
1379
1494
  prependListener(
1380
1495
  event: "stream",
@@ -1385,13 +1500,16 @@ declare module "http2" {
1385
1500
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1386
1501
  prependOnceListener(
1387
1502
  event: "checkContinue",
1388
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1503
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1389
1504
  ): this;
1390
1505
  prependOnceListener(
1391
1506
  event: "request",
1392
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1507
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1508
+ ): this;
1509
+ prependOnceListener(
1510
+ event: "session",
1511
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1393
1512
  ): this;
1394
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1395
1513
  prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1396
1514
  prependOnceListener(
1397
1515
  event: "stream",
@@ -1422,7 +1540,7 @@ declare module "http2" {
1422
1540
  readonly aborted: boolean;
1423
1541
  /**
1424
1542
  * 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']`.
1543
+ * 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
1544
  * @since v8.4.0
1427
1545
  */
1428
1546
  readonly authority: string;
@@ -1450,7 +1568,7 @@ declare module "http2" {
1450
1568
  * // host: '127.0.0.1:8000',
1451
1569
  * // accept: '*' }
1452
1570
  * console.log(request.headers);
1453
- * ```
1571
+ * ```f
1454
1572
  *
1455
1573
  * See `HTTP/2 Headers Object`.
1456
1574
  *
@@ -1469,9 +1587,9 @@ declare module "http2" {
1469
1587
  readonly headers: IncomingHttpHeaders;
1470
1588
  /**
1471
1589
  * 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'`.
1590
+ * client response, the HTTP version of the connected-to server. Returns `'2.0'`.
1473
1591
  *
1474
- * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
1592
+ * Also `message.httpVersionMajor` is the first integer and `message.httpVersionMinor` is the second.
1475
1593
  * @since v8.4.0
1476
1594
  */
1477
1595
  readonly httpVersion: string;
@@ -1526,11 +1644,11 @@ declare module "http2" {
1526
1644
  * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1527
1645
  * set on `request.stream`.
1528
1646
  *
1529
- * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`request.stream`.
1647
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on `request.stream`.
1530
1648
  *
1531
1649
  * `setTimeout` method will be called on `request.stream.session`.
1532
1650
  *
1533
- * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1651
+ * `pause`, `read`, `resume`, and `write` will throw an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1534
1652
  * more information.
1535
1653
  *
1536
1654
  * All other interactions will be routed directly to the socket. With TLS support,
@@ -1593,7 +1711,7 @@ declare module "http2" {
1593
1711
  * the response object.
1594
1712
  *
1595
1713
  * 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
1714
+ * the server, then `Http2Stream`s are destroyed when they time out. If a
1597
1715
  * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly.
1598
1716
  * @since v8.4.0
1599
1717
  */
@@ -1647,7 +1765,7 @@ declare module "http2" {
1647
1765
  * passed as the second parameter to the `'request'` event.
1648
1766
  * @since v8.4.0
1649
1767
  */
1650
- export class Http2ServerResponse extends stream.Writable {
1768
+ export class Http2ServerResponse<Request extends Http2ServerRequest = Http2ServerRequest> extends stream.Writable {
1651
1769
  constructor(stream: ServerHttp2Stream);
1652
1770
  /**
1653
1771
  * See `response.socket`.
@@ -1668,10 +1786,10 @@ declare module "http2" {
1668
1786
  */
1669
1787
  readonly headersSent: boolean;
1670
1788
  /**
1671
- * A reference to the original HTTP2 request object.
1789
+ * A reference to the original HTTP2 `request` object.
1672
1790
  * @since v15.7.0
1673
1791
  */
1674
- readonly req: Http2ServerRequest;
1792
+ readonly req: Request;
1675
1793
  /**
1676
1794
  * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but
1677
1795
  * applies getters, setters, and methods based on HTTP/2 logic.
@@ -1679,11 +1797,11 @@ declare module "http2" {
1679
1797
  * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1680
1798
  * set on `response.stream`.
1681
1799
  *
1682
- * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`response.stream`.
1800
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on `response.stream`.
1683
1801
  *
1684
1802
  * `setTimeout` method will be called on `response.stream.session`.
1685
1803
  *
1686
- * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1804
+ * `pause`, `read`, `resume`, and `write` will throw an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1687
1805
  * more information.
1688
1806
  *
1689
1807
  * All other interactions will be routed directly to the socket.
@@ -1787,7 +1905,7 @@ declare module "http2" {
1787
1905
  * header names and the values are the respective header values. All header names
1788
1906
  * are lowercase.
1789
1907
  *
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()`,
1908
+ * 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
1909
  * `obj.hasOwnProperty()`, and others
1792
1910
  * are not defined and _will not work_.
1793
1911
  *
@@ -1861,7 +1979,7 @@ declare module "http2" {
1861
1979
  *
1862
1980
  * If no `'timeout'` listener is added to the request, the response, or
1863
1981
  * 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.
1982
+ * handler is assigned to the request, the response, or the server's `'timeout'` events, timed out sockets must be handled explicitly.
1865
1983
  * @since v8.4.0
1866
1984
  */
1867
1985
  setTimeout(msecs: number, callback?: () => void): void;
@@ -1872,8 +1990,8 @@ declare module "http2" {
1872
1990
  * This sends a chunk of the response body. This method may
1873
1991
  * be called multiple times to provide successive parts of the body.
1874
1992
  *
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.
1993
+ * In the `node:http` module, the response body is omitted when the
1994
+ * request is a HEAD request. Similarly, the `204` and `304` responses _must not_ include a message body.
1877
1995
  *
1878
1996
  * `chunk` can be a string or a buffer. If `chunk` is a string,
1879
1997
  * the second parameter specifies how to encode it into a byte stream.
@@ -1923,7 +2041,7 @@ declare module "http2" {
1923
2041
  * `Content-Length` is given in bytes not characters. The`Buffer.byteLength()` API may be used to determine the number of bytes in a
1924
2042
  * given encoding. On outbound messages, Node.js does not check if Content-Length
1925
2043
  * 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.
2044
+ * receiving messages, Node.js will automatically reject messages when the `Content-Length` does not match the actual payload size.
1927
2045
  *
1928
2046
  * This method may be called at most one time on a message before `response.end()` is called.
1929
2047
  *
@@ -2229,7 +2347,7 @@ declare module "http2" {
2229
2347
  */
2230
2348
  export const sensitiveHeaders: symbol;
2231
2349
  /**
2232
- * Returns an object containing the default settings for an `Http2Session`instance. This method returns a new object instance every time it is called
2350
+ * Returns an object containing the default settings for an `Http2Session` instance. This method returns a new object instance every time it is called
2233
2351
  * so instances returned may be safely modified for use.
2234
2352
  * @since v8.4.0
2235
2353
  */
@@ -2258,7 +2376,7 @@ declare module "http2" {
2258
2376
  */
2259
2377
  export function getUnpackedSettings(buf: Uint8Array): Settings;
2260
2378
  /**
2261
- * Returns a `net.Server` instance that creates and manages `Http2Session`instances.
2379
+ * Returns a `net.Server` instance that creates and manages `Http2Session` instances.
2262
2380
  *
2263
2381
  * 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
2382
  * communicating
@@ -2276,12 +2394,12 @@ declare module "http2" {
2276
2394
  * server.on('stream', (stream, headers) => {
2277
2395
  * stream.respond({
2278
2396
  * 'content-type': 'text/html; charset=utf-8',
2279
- * ':status': 200
2397
+ * ':status': 200,
2280
2398
  * });
2281
2399
  * stream.end('<h1>Hello World</h1>');
2282
2400
  * });
2283
2401
  *
2284
- * server.listen(80);
2402
+ * server.listen(8000);
2285
2403
  * ```
2286
2404
  * @since v8.4.0
2287
2405
  * @param onRequestHandler See `Compatibility API`
@@ -2289,12 +2407,17 @@ declare module "http2" {
2289
2407
  export function createServer(
2290
2408
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2291
2409
  ): Http2Server;
2292
- export function createServer(
2293
- options: ServerOptions,
2294
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2295
- ): Http2Server;
2410
+ export function createServer<
2411
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2412
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
2413
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2414
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
2415
+ >(
2416
+ options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2417
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2418
+ ): Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>;
2296
2419
  /**
2297
- * Returns a `tls.Server` instance that creates and manages `Http2Session`instances.
2420
+ * Returns a `tls.Server` instance that creates and manages `Http2Session` instances.
2298
2421
  *
2299
2422
  * ```js
2300
2423
  * const http2 = require('http2');
@@ -2302,7 +2425,7 @@ declare module "http2" {
2302
2425
  *
2303
2426
  * const options = {
2304
2427
  * key: fs.readFileSync('server-key.pem'),
2305
- * cert: fs.readFileSync('server-cert.pem')
2428
+ * cert: fs.readFileSync('server-cert.pem'),
2306
2429
  * };
2307
2430
  *
2308
2431
  * // Create a secure HTTP/2 server
@@ -2311,12 +2434,12 @@ declare module "http2" {
2311
2434
  * server.on('stream', (stream, headers) => {
2312
2435
  * stream.respond({
2313
2436
  * 'content-type': 'text/html; charset=utf-8',
2314
- * ':status': 200
2437
+ * ':status': 200,
2315
2438
  * });
2316
2439
  * stream.end('<h1>Hello World</h1>');
2317
2440
  * });
2318
2441
  *
2319
- * server.listen(80);
2442
+ * server.listen(8443);
2320
2443
  * ```
2321
2444
  * @since v8.4.0
2322
2445
  * @param onRequestHandler See `Compatibility API`
@@ -2324,10 +2447,15 @@ declare module "http2" {
2324
2447
  export function createSecureServer(
2325
2448
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2326
2449
  ): Http2SecureServer;
2327
- export function createSecureServer(
2328
- options: SecureServerOptions,
2329
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2330
- ): Http2SecureServer;
2450
+ export function createSecureServer<
2451
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2452
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
2453
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2454
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
2455
+ >(
2456
+ options: SecureServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2457
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2458
+ ): Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
2331
2459
  /**
2332
2460
  * Returns a `ClientHttp2Session` instance.
2333
2461
  *
node v16.18/https.d.ts CHANGED
@@ -10,7 +10,7 @@ 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
14
  > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
15
15
  type RequestOptions =
16
16
  & http.RequestOptions
@@ -34,7 +34,7 @@ declare module "https" {
34
34
  }
35
35
  interface Server<
36
36
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
37
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
37
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
38
38
  > extends http.Server<Request, Response> {}
39
39
  /**
40
40
  * See `http.Server` for more information.
@@ -42,7 +42,7 @@ declare module "https" {
42
42
  */
43
43
  class Server<
44
44
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
45
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
45
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
46
46
  > extends tls.Server {
47
47
  constructor(requestListener?: http.RequestListener<Request, Response>);
48
48
  constructor(
@@ -109,19 +109,19 @@ declare module "https" {
109
109
  emit(
110
110
  event: "checkContinue",
111
111
  req: InstanceType<Request>,
112
- res: InstanceType<Response> & { req: InstanceType<Request> },
112
+ res: InstanceType<Response>,
113
113
  ): boolean;
114
114
  emit(
115
115
  event: "checkExpectation",
116
116
  req: InstanceType<Request>,
117
- res: InstanceType<Response> & { req: InstanceType<Request> },
117
+ res: InstanceType<Response>,
118
118
  ): boolean;
119
119
  emit(event: "clientError", err: Error, socket: Duplex): boolean;
120
120
  emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
121
121
  emit(
122
122
  event: "request",
123
123
  req: InstanceType<Request>,
124
- res: InstanceType<Response> & { req: InstanceType<Request> },
124
+ res: InstanceType<Response>,
125
125
  ): boolean;
126
126
  emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
127
127
  on(event: string, listener: (...args: any[]) => void): this;
@@ -296,11 +296,11 @@ declare module "https" {
296
296
  */
297
297
  function createServer<
298
298
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
299
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
299
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
300
300
  >(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
301
301
  function createServer<
302
302
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
303
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
303
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
304
304
  >(
305
305
  options: ServerOptions<Request, Response>,
306
306
  requestListener?: http.RequestListener<Request, Response>,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "16.18.108",
3
+ "version": "16.18.109",
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": "eefbc030a82672d0a58c0ef369e7bc503e92d6ff5124e24b8b49696e86460e6a",
213
+ "typesPublisherContentHash": "f7aeca3a5c126e5fe0326f911445d3f32dec22f907b425be2e2cd6a672fa47c4",
214
214
  "typeScriptVersion": "4.8"
215
215
  }