@types/node 18.19.50 → 18.19.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
node v18.19/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/v18.
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: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
@@ -123,10 +123,22 @@ declare global {
123
123
  // Same as module.exports
124
124
  var exports: any;
125
125
 
126
+ interface GCFunction {
127
+ (options: {
128
+ execution?: "sync";
129
+ type?: "major" | "minor";
130
+ }): void;
131
+ (options: {
132
+ execution: "async";
133
+ type?: "major" | "minor";
134
+ }): Promise<void>;
135
+ (options?: boolean): void;
136
+ }
137
+
126
138
  /**
127
139
  * Only available if `--expose-gc` is passed to the process.
128
140
  */
129
- var gc: undefined | (() => void);
141
+ var gc: undefined | GCFunction;
130
142
 
131
143
  // #region borrowed
132
144
  // from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib
node v18.19/http.d.ts CHANGED
@@ -231,7 +231,7 @@ declare module "http" {
231
231
  }
232
232
  interface ServerOptions<
233
233
  Request extends typeof IncomingMessage = typeof IncomingMessage,
234
- Response extends typeof ServerResponse = typeof ServerResponse,
234
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
235
235
  > {
236
236
  /**
237
237
  * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
@@ -316,14 +316,14 @@ declare module "http" {
316
316
  }
317
317
  type RequestListener<
318
318
  Request extends typeof IncomingMessage = typeof IncomingMessage,
319
- Response extends typeof ServerResponse = typeof ServerResponse,
319
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
320
320
  > = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
321
321
  /**
322
322
  * @since v0.1.17
323
323
  */
324
324
  class Server<
325
325
  Request extends typeof IncomingMessage = typeof IncomingMessage,
326
- Response extends typeof ServerResponse = typeof ServerResponse,
326
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
327
327
  > extends NetServer {
328
328
  constructor(requestListener?: RequestListener<Request, Response>);
329
329
  constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
@@ -1499,11 +1499,11 @@ declare module "http" {
1499
1499
  */
1500
1500
  function createServer<
1501
1501
  Request extends typeof IncomingMessage = typeof IncomingMessage,
1502
- Response extends typeof ServerResponse = typeof ServerResponse,
1502
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
1503
1503
  >(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
1504
1504
  function createServer<
1505
1505
  Request extends typeof IncomingMessage = typeof IncomingMessage,
1506
- Response extends typeof ServerResponse = typeof ServerResponse,
1506
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
1507
1507
  >(
1508
1508
  options: ServerOptions<Request, Response>,
1509
1509
  requestListener?: RequestListener<Request, Response>,
node v18.19/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;
@@ -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,22 +921,22 @@ 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
  * When a `ClientHttp2Session` is first created, the socket may not yet be
925
928
  * connected. if `clienthttp2session.request()` is called during this time, the
926
929
  * actual request will be deferred until the socket is ready to go.
927
- * If the `session` is closed before the actual request be executed, an`ERR_HTTP2_GOAWAY_SESSION` is thrown.
930
+ * If the `session` is closed before the actual request be executed, an `ERR_HTTP2_GOAWAY_SESSION` is thrown.
928
931
  *
929
- * This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`.
932
+ * This method is only available if `http2session.type` is equal to `http2.constants.NGHTTP2_SESSION_CLIENT`.
930
933
  *
931
934
  * ```js
932
935
  * const http2 = require('http2');
933
936
  * const clientSession = http2.connect('https://localhost:1234');
934
937
  * const {
935
938
  * HTTP2_HEADER_PATH,
936
- * HTTP2_HEADER_STATUS
939
+ * HTTP2_HEADER_STATUS,
937
940
  * } = http2.constants;
938
941
  *
939
942
  * const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' });
@@ -1049,8 +1052,15 @@ declare module "http2" {
1049
1052
  export interface AlternativeServiceOptions {
1050
1053
  origin: number | string | url.URL;
1051
1054
  }
1052
- export interface ServerHttp2Session extends Http2Session {
1053
- readonly server: Http2Server | Http2SecureServer;
1055
+ export interface ServerHttp2Session<
1056
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1057
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1058
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1059
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1060
+ > extends Http2Session {
1061
+ readonly server:
1062
+ | Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>
1063
+ | Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
1054
1064
  /**
1055
1065
  * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.
1056
1066
  *
@@ -1109,7 +1119,7 @@ declare module "http2" {
1109
1119
  * ```
1110
1120
  *
1111
1121
  * When a string is passed as an `origin`, it will be parsed as a URL and the
1112
- * 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
1122
+ * 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
1113
1123
  * string
1114
1124
  * cannot be parsed as a URL or if a valid origin cannot be derived.
1115
1125
  *
@@ -1145,17 +1155,30 @@ declare module "http2" {
1145
1155
  ): void;
1146
1156
  addListener(
1147
1157
  event: "connect",
1148
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1158
+ listener: (
1159
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1160
+ socket: net.Socket | tls.TLSSocket,
1161
+ ) => void,
1149
1162
  ): this;
1150
1163
  addListener(
1151
1164
  event: "stream",
1152
1165
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1153
1166
  ): this;
1154
1167
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1155
- emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
1168
+ emit(
1169
+ event: "connect",
1170
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1171
+ socket: net.Socket | tls.TLSSocket,
1172
+ ): boolean;
1156
1173
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1157
1174
  emit(event: string | symbol, ...args: any[]): boolean;
1158
- on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
1175
+ on(
1176
+ event: "connect",
1177
+ listener: (
1178
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1179
+ socket: net.Socket | tls.TLSSocket,
1180
+ ) => void,
1181
+ ): this;
1159
1182
  on(
1160
1183
  event: "stream",
1161
1184
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1163,7 +1186,10 @@ declare module "http2" {
1163
1186
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1164
1187
  once(
1165
1188
  event: "connect",
1166
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1189
+ listener: (
1190
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1191
+ socket: net.Socket | tls.TLSSocket,
1192
+ ) => void,
1167
1193
  ): this;
1168
1194
  once(
1169
1195
  event: "stream",
@@ -1172,7 +1198,10 @@ declare module "http2" {
1172
1198
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1173
1199
  prependListener(
1174
1200
  event: "connect",
1175
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1201
+ listener: (
1202
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1203
+ socket: net.Socket | tls.TLSSocket,
1204
+ ) => void,
1176
1205
  ): this;
1177
1206
  prependListener(
1178
1207
  event: "stream",
@@ -1181,7 +1210,10 @@ declare module "http2" {
1181
1210
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1182
1211
  prependOnceListener(
1183
1212
  event: "connect",
1184
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1213
+ listener: (
1214
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1215
+ socket: net.Socket | tls.TLSSocket,
1216
+ ) => void,
1185
1217
  ): this;
1186
1218
  prependOnceListener(
1187
1219
  event: "stream",
@@ -1213,16 +1245,36 @@ declare module "http2" {
1213
1245
  createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined;
1214
1246
  protocol?: "http:" | "https:" | undefined;
1215
1247
  }
1216
- export interface ServerSessionOptions extends SessionOptions {
1217
- Http1IncomingMessage?: typeof IncomingMessage | undefined;
1218
- Http1ServerResponse?: typeof ServerResponse | undefined;
1219
- Http2ServerRequest?: typeof Http2ServerRequest | undefined;
1220
- Http2ServerResponse?: typeof Http2ServerResponse | undefined;
1248
+ export interface ServerSessionOptions<
1249
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1250
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1251
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1252
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1253
+ > extends SessionOptions {
1254
+ Http1IncomingMessage?: Http1Request | undefined;
1255
+ Http1ServerResponse?: Http1Response | undefined;
1256
+ Http2ServerRequest?: Http2Request | undefined;
1257
+ Http2ServerResponse?: Http2Response | undefined;
1221
1258
  }
1222
1259
  export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions {}
1223
- export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions {}
1224
- export interface ServerOptions extends ServerSessionOptions {}
1225
- export interface SecureServerOptions extends SecureServerSessionOptions {
1260
+ export interface SecureServerSessionOptions<
1261
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1262
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1263
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1264
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1265
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response>, tls.TlsOptions {}
1266
+ export interface ServerOptions<
1267
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1268
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1269
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1270
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1271
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {}
1272
+ export interface SecureServerOptions<
1273
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1274
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1275
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1276
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1277
+ > extends SecureServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {
1226
1278
  allowHTTP1?: boolean | undefined;
1227
1279
  origins?: string[] | undefined;
1228
1280
  }
@@ -1234,16 +1286,24 @@ declare module "http2" {
1234
1286
  */
1235
1287
  updateSettings(settings: Settings): void;
1236
1288
  }
1237
- export interface Http2Server extends net.Server, HTTP2ServerCommon {
1289
+ export interface Http2Server<
1290
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1291
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1292
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1293
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1294
+ > extends net.Server, HTTP2ServerCommon {
1238
1295
  addListener(
1239
1296
  event: "checkContinue",
1240
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1297
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1241
1298
  ): this;
1242
1299
  addListener(
1243
1300
  event: "request",
1244
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1301
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1302
+ ): this;
1303
+ addListener(
1304
+ event: "session",
1305
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1245
1306
  ): this;
1246
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1247
1307
  addListener(event: "sessionError", listener: (err: Error) => void): this;
1248
1308
  addListener(
1249
1309
  event: "stream",
@@ -1251,19 +1311,32 @@ declare module "http2" {
1251
1311
  ): this;
1252
1312
  addListener(event: "timeout", listener: () => void): this;
1253
1313
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1254
- emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1255
- emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1256
- emit(event: "session", session: ServerHttp2Session): boolean;
1314
+ emit(
1315
+ event: "checkContinue",
1316
+ request: InstanceType<Http2Request>,
1317
+ response: InstanceType<Http2Response>,
1318
+ ): boolean;
1319
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1320
+ emit(
1321
+ event: "session",
1322
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1323
+ ): boolean;
1257
1324
  emit(event: "sessionError", err: Error): boolean;
1258
1325
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1259
1326
  emit(event: "timeout"): boolean;
1260
1327
  emit(event: string | symbol, ...args: any[]): boolean;
1261
1328
  on(
1262
1329
  event: "checkContinue",
1263
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1330
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1331
+ ): this;
1332
+ on(
1333
+ event: "request",
1334
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1335
+ ): this;
1336
+ on(
1337
+ event: "session",
1338
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1264
1339
  ): this;
1265
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1266
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1267
1340
  on(event: "sessionError", listener: (err: Error) => void): this;
1268
1341
  on(
1269
1342
  event: "stream",
@@ -1273,10 +1346,16 @@ declare module "http2" {
1273
1346
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1274
1347
  once(
1275
1348
  event: "checkContinue",
1276
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1349
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1350
+ ): this;
1351
+ once(
1352
+ event: "request",
1353
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1354
+ ): this;
1355
+ once(
1356
+ event: "session",
1357
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1277
1358
  ): this;
1278
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1279
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1280
1359
  once(event: "sessionError", listener: (err: Error) => void): this;
1281
1360
  once(
1282
1361
  event: "stream",
@@ -1286,13 +1365,16 @@ declare module "http2" {
1286
1365
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1287
1366
  prependListener(
1288
1367
  event: "checkContinue",
1289
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1368
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1290
1369
  ): this;
1291
1370
  prependListener(
1292
1371
  event: "request",
1293
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1372
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1373
+ ): this;
1374
+ prependListener(
1375
+ event: "session",
1376
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1294
1377
  ): this;
1295
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1296
1378
  prependListener(event: "sessionError", listener: (err: Error) => void): this;
1297
1379
  prependListener(
1298
1380
  event: "stream",
@@ -1302,13 +1384,16 @@ declare module "http2" {
1302
1384
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1303
1385
  prependOnceListener(
1304
1386
  event: "checkContinue",
1305
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1387
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1306
1388
  ): this;
1307
1389
  prependOnceListener(
1308
1390
  event: "request",
1309
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1391
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1392
+ ): this;
1393
+ prependOnceListener(
1394
+ event: "session",
1395
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1310
1396
  ): this;
1311
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1312
1397
  prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1313
1398
  prependOnceListener(
1314
1399
  event: "stream",
@@ -1317,16 +1402,24 @@ declare module "http2" {
1317
1402
  prependOnceListener(event: "timeout", listener: () => void): this;
1318
1403
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1319
1404
  }
1320
- export interface Http2SecureServer extends tls.Server, HTTP2ServerCommon {
1405
+ export interface Http2SecureServer<
1406
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1407
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1408
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1409
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1410
+ > extends tls.Server, HTTP2ServerCommon {
1321
1411
  addListener(
1322
1412
  event: "checkContinue",
1323
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1413
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1324
1414
  ): this;
1325
1415
  addListener(
1326
1416
  event: "request",
1327
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1417
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1418
+ ): this;
1419
+ addListener(
1420
+ event: "session",
1421
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1328
1422
  ): this;
1329
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1330
1423
  addListener(event: "sessionError", listener: (err: Error) => void): this;
1331
1424
  addListener(
1332
1425
  event: "stream",
@@ -1335,9 +1428,16 @@ declare module "http2" {
1335
1428
  addListener(event: "timeout", listener: () => void): this;
1336
1429
  addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1337
1430
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1338
- emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1339
- emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1340
- emit(event: "session", session: ServerHttp2Session): boolean;
1431
+ emit(
1432
+ event: "checkContinue",
1433
+ request: InstanceType<Http2Request>,
1434
+ response: InstanceType<Http2Response>,
1435
+ ): boolean;
1436
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1437
+ emit(
1438
+ event: "session",
1439
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1440
+ ): boolean;
1341
1441
  emit(event: "sessionError", err: Error): boolean;
1342
1442
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1343
1443
  emit(event: "timeout"): boolean;
@@ -1345,10 +1445,16 @@ declare module "http2" {
1345
1445
  emit(event: string | symbol, ...args: any[]): boolean;
1346
1446
  on(
1347
1447
  event: "checkContinue",
1348
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1448
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1449
+ ): this;
1450
+ on(
1451
+ event: "request",
1452
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1453
+ ): this;
1454
+ on(
1455
+ event: "session",
1456
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1349
1457
  ): this;
1350
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1351
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1352
1458
  on(event: "sessionError", listener: (err: Error) => void): this;
1353
1459
  on(
1354
1460
  event: "stream",
@@ -1359,10 +1465,16 @@ declare module "http2" {
1359
1465
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1360
1466
  once(
1361
1467
  event: "checkContinue",
1362
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1468
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1469
+ ): this;
1470
+ once(
1471
+ event: "request",
1472
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1473
+ ): this;
1474
+ once(
1475
+ event: "session",
1476
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1363
1477
  ): this;
1364
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1365
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1366
1478
  once(event: "sessionError", listener: (err: Error) => void): this;
1367
1479
  once(
1368
1480
  event: "stream",
@@ -1373,13 +1485,16 @@ declare module "http2" {
1373
1485
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1374
1486
  prependListener(
1375
1487
  event: "checkContinue",
1376
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1488
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1377
1489
  ): this;
1378
1490
  prependListener(
1379
1491
  event: "request",
1380
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1492
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1493
+ ): this;
1494
+ prependListener(
1495
+ event: "session",
1496
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1381
1497
  ): this;
1382
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1383
1498
  prependListener(event: "sessionError", listener: (err: Error) => void): this;
1384
1499
  prependListener(
1385
1500
  event: "stream",
@@ -1390,13 +1505,16 @@ declare module "http2" {
1390
1505
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1391
1506
  prependOnceListener(
1392
1507
  event: "checkContinue",
1393
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1508
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1394
1509
  ): this;
1395
1510
  prependOnceListener(
1396
1511
  event: "request",
1397
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1512
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1513
+ ): this;
1514
+ prependOnceListener(
1515
+ event: "session",
1516
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1398
1517
  ): this;
1399
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1400
1518
  prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1401
1519
  prependOnceListener(
1402
1520
  event: "stream",
@@ -1427,7 +1545,7 @@ declare module "http2" {
1427
1545
  readonly aborted: boolean;
1428
1546
  /**
1429
1547
  * The request authority pseudo header field. Because HTTP/2 allows requests
1430
- * to set either `:authority` or `host`, this value is derived from`req.headers[':authority']` if present. Otherwise, it is derived from`req.headers['host']`.
1548
+ * to set either `:authority` or `host`, this value is derived from `req.headers[':authority']` if present. Otherwise, it is derived from `req.headers['host']`.
1431
1549
  * @since v8.4.0
1432
1550
  */
1433
1551
  readonly authority: string;
@@ -1474,9 +1592,9 @@ declare module "http2" {
1474
1592
  readonly headers: IncomingHttpHeaders;
1475
1593
  /**
1476
1594
  * In case of server request, the HTTP version sent by the client. In the case of
1477
- * client response, the HTTP version of the connected-to server. Returns`'2.0'`.
1595
+ * client response, the HTTP version of the connected-to server. Returns `'2.0'`.
1478
1596
  *
1479
- * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
1597
+ * Also `message.httpVersionMajor` is the first integer and `message.httpVersionMinor` is the second.
1480
1598
  * @since v8.4.0
1481
1599
  */
1482
1600
  readonly httpVersion: string;
@@ -1531,11 +1649,11 @@ declare module "http2" {
1531
1649
  * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1532
1650
  * set on `request.stream`.
1533
1651
  *
1534
- * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`request.stream`.
1652
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on `request.stream`.
1535
1653
  *
1536
1654
  * `setTimeout` method will be called on `request.stream.session`.
1537
1655
  *
1538
- * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1656
+ * `pause`, `read`, `resume`, and `write` will throw an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1539
1657
  * more information.
1540
1658
  *
1541
1659
  * All other interactions will be routed directly to the socket. With TLS support,
@@ -1598,7 +1716,7 @@ declare module "http2" {
1598
1716
  * the response object.
1599
1717
  *
1600
1718
  * If no `'timeout'` listener is added to the request, the response, or
1601
- * the server, then `Http2Stream` s are destroyed when they time out. If a
1719
+ * the server, then `Http2Stream`s are destroyed when they time out. If a
1602
1720
  * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly.
1603
1721
  * @since v8.4.0
1604
1722
  */
@@ -1652,7 +1770,7 @@ declare module "http2" {
1652
1770
  * passed as the second parameter to the `'request'` event.
1653
1771
  * @since v8.4.0
1654
1772
  */
1655
- export class Http2ServerResponse extends stream.Writable {
1773
+ export class Http2ServerResponse<Request extends Http2ServerRequest = Http2ServerRequest> extends stream.Writable {
1656
1774
  constructor(stream: ServerHttp2Stream);
1657
1775
  /**
1658
1776
  * See `response.socket`.
@@ -1673,10 +1791,10 @@ declare module "http2" {
1673
1791
  */
1674
1792
  readonly headersSent: boolean;
1675
1793
  /**
1676
- * A reference to the original HTTP2 request object.
1794
+ * A reference to the original HTTP2 `request` object.
1677
1795
  * @since v15.7.0
1678
1796
  */
1679
- readonly req: Http2ServerRequest;
1797
+ readonly req: Request;
1680
1798
  /**
1681
1799
  * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but
1682
1800
  * applies getters, setters, and methods based on HTTP/2 logic.
@@ -1684,11 +1802,11 @@ declare module "http2" {
1684
1802
  * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1685
1803
  * set on `response.stream`.
1686
1804
  *
1687
- * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`response.stream`.
1805
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on `response.stream`.
1688
1806
  *
1689
1807
  * `setTimeout` method will be called on `response.stream.session`.
1690
1808
  *
1691
- * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1809
+ * `pause`, `read`, `resume`, and `write` will throw an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1692
1810
  * more information.
1693
1811
  *
1694
1812
  * All other interactions will be routed directly to the socket.
@@ -1792,7 +1910,7 @@ declare module "http2" {
1792
1910
  * header names and the values are the respective header values. All header names
1793
1911
  * are lowercase.
1794
1912
  *
1795
- * 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()`,
1913
+ * 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()`,
1796
1914
  * `obj.hasOwnProperty()`, and others
1797
1915
  * are not defined and _will not work_.
1798
1916
  *
@@ -1866,7 +1984,7 @@ declare module "http2" {
1866
1984
  *
1867
1985
  * If no `'timeout'` listener is added to the request, the response, or
1868
1986
  * the server, then `Http2Stream` s are destroyed when they time out. If a
1869
- * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly.
1987
+ * handler is assigned to the request, the response, or the server's `'timeout'` events, timed out sockets must be handled explicitly.
1870
1988
  * @since v8.4.0
1871
1989
  */
1872
1990
  setTimeout(msecs: number, callback?: () => void): void;
@@ -1912,7 +2030,7 @@ declare module "http2" {
1912
2030
  * The `hints` is an object containing the values of headers to be sent with
1913
2031
  * early hints message.
1914
2032
  *
1915
- * Example:
2033
+ * **Example**
1916
2034
  *
1917
2035
  * ```js
1918
2036
  * const earlyHintsLink = '</styles.css>; rel=preload; as=style';
@@ -1926,12 +2044,9 @@ declare module "http2" {
1926
2044
  * ];
1927
2045
  * response.writeEarlyHints({
1928
2046
  * 'link': earlyHintsLinks,
1929
- * 'x-trace-id': 'id for diagnostics'
1930
2047
  * });
1931
2048
  * ```
1932
- *
1933
2049
  * @since v18.11.0
1934
- * @param hints An object containing the values of headers
1935
2050
  */
1936
2051
  writeEarlyHints(hints: Record<string, string | string[]>): void;
1937
2052
  /**
@@ -1956,7 +2071,7 @@ declare module "http2" {
1956
2071
  * `Content-Length` is given in bytes not characters. The`Buffer.byteLength()` API may be used to determine the number of bytes in a
1957
2072
  * given encoding. On outbound messages, Node.js does not check if Content-Length
1958
2073
  * and the length of the body being transmitted are equal or not. However, when
1959
- * receiving messages, Node.js will automatically reject messages when the`Content-Length` does not match the actual payload size.
2074
+ * receiving messages, Node.js will automatically reject messages when the `Content-Length` does not match the actual payload size.
1960
2075
  *
1961
2076
  * This method may be called at most one time on a message before `response.end()` is called.
1962
2077
  *
@@ -2262,7 +2377,7 @@ declare module "http2" {
2262
2377
  */
2263
2378
  export const sensitiveHeaders: symbol;
2264
2379
  /**
2265
- * Returns an object containing the default settings for an `Http2Session`instance. This method returns a new object instance every time it is called
2380
+ * Returns an object containing the default settings for an `Http2Session` instance. This method returns a new object instance every time it is called
2266
2381
  * so instances returned may be safely modified for use.
2267
2382
  * @since v8.4.0
2268
2383
  */
@@ -2291,7 +2406,7 @@ declare module "http2" {
2291
2406
  */
2292
2407
  export function getUnpackedSettings(buf: Uint8Array): Settings;
2293
2408
  /**
2294
- * Returns a `net.Server` instance that creates and manages `Http2Session`instances.
2409
+ * Returns a `net.Server` instance that creates and manages `Http2Session` instances.
2295
2410
  *
2296
2411
  * 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
2297
2412
  * communicating
@@ -2309,12 +2424,12 @@ declare module "http2" {
2309
2424
  * server.on('stream', (stream, headers) => {
2310
2425
  * stream.respond({
2311
2426
  * 'content-type': 'text/html; charset=utf-8',
2312
- * ':status': 200
2427
+ * ':status': 200,
2313
2428
  * });
2314
2429
  * stream.end('<h1>Hello World</h1>');
2315
2430
  * });
2316
2431
  *
2317
- * server.listen(80);
2432
+ * server.listen(8000);
2318
2433
  * ```
2319
2434
  * @since v8.4.0
2320
2435
  * @param onRequestHandler See `Compatibility API`
@@ -2322,12 +2437,17 @@ declare module "http2" {
2322
2437
  export function createServer(
2323
2438
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2324
2439
  ): Http2Server;
2325
- export function createServer(
2326
- options: ServerOptions,
2327
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2328
- ): Http2Server;
2440
+ export function createServer<
2441
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2442
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
2443
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2444
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
2445
+ >(
2446
+ options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2447
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2448
+ ): Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>;
2329
2449
  /**
2330
- * Returns a `tls.Server` instance that creates and manages `Http2Session`instances.
2450
+ * Returns a `tls.Server` instance that creates and manages `Http2Session` instances.
2331
2451
  *
2332
2452
  * ```js
2333
2453
  * const http2 = require('http2');
@@ -2335,7 +2455,7 @@ declare module "http2" {
2335
2455
  *
2336
2456
  * const options = {
2337
2457
  * key: fs.readFileSync('server-key.pem'),
2338
- * cert: fs.readFileSync('server-cert.pem')
2458
+ * cert: fs.readFileSync('server-cert.pem'),
2339
2459
  * };
2340
2460
  *
2341
2461
  * // Create a secure HTTP/2 server
@@ -2344,12 +2464,12 @@ declare module "http2" {
2344
2464
  * server.on('stream', (stream, headers) => {
2345
2465
  * stream.respond({
2346
2466
  * 'content-type': 'text/html; charset=utf-8',
2347
- * ':status': 200
2467
+ * ':status': 200,
2348
2468
  * });
2349
2469
  * stream.end('<h1>Hello World</h1>');
2350
2470
  * });
2351
2471
  *
2352
- * server.listen(80);
2472
+ * server.listen(8443);
2353
2473
  * ```
2354
2474
  * @since v8.4.0
2355
2475
  * @param onRequestHandler See `Compatibility API`
@@ -2357,10 +2477,15 @@ declare module "http2" {
2357
2477
  export function createSecureServer(
2358
2478
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2359
2479
  ): Http2SecureServer;
2360
- export function createSecureServer(
2361
- options: SecureServerOptions,
2362
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2363
- ): Http2SecureServer;
2480
+ export function createSecureServer<
2481
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2482
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
2483
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2484
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
2485
+ >(
2486
+ options: SecureServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2487
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2488
+ ): Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
2364
2489
  /**
2365
2490
  * Returns a `ClientHttp2Session` instance.
2366
2491
  *
node v18.19/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(
@@ -119,19 +119,19 @@ declare module "https" {
119
119
  emit(
120
120
  event: "checkContinue",
121
121
  req: InstanceType<Request>,
122
- res: InstanceType<Response> & { req: InstanceType<Request> },
122
+ res: InstanceType<Response>,
123
123
  ): boolean;
124
124
  emit(
125
125
  event: "checkExpectation",
126
126
  req: InstanceType<Request>,
127
- res: InstanceType<Response> & { req: InstanceType<Request> },
127
+ res: InstanceType<Response>,
128
128
  ): boolean;
129
129
  emit(event: "clientError", err: Error, socket: Duplex): boolean;
130
130
  emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
131
131
  emit(
132
132
  event: "request",
133
133
  req: InstanceType<Request>,
134
- res: InstanceType<Response> & { req: InstanceType<Request> },
134
+ res: InstanceType<Response>,
135
135
  ): boolean;
136
136
  emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
137
137
  on(event: string, listener: (...args: any[]) => void): this;
@@ -306,11 +306,11 @@ declare module "https" {
306
306
  */
307
307
  function createServer<
308
308
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
309
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
309
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
310
310
  >(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
311
311
  function createServer<
312
312
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
313
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
313
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
314
314
  >(
315
315
  options: ServerOptions<Request, Response>,
316
316
  requestListener?: http.RequestListener<Request, Response>,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.19.50",
3
+ "version": "18.19.51",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -217,6 +217,6 @@
217
217
  "dependencies": {
218
218
  "undici-types": "~5.26.4"
219
219
  },
220
- "typesPublisherContentHash": "5ce9cffaeee72821d1d992438407df2493e219642e4b4d833ac5a9ef3b70161c",
220
+ "typesPublisherContentHash": "3f2c9f0fc2f4642d5fa85bb2709a86e174b8b756a1a4d37778ae338ad1cd7dbd",
221
221
  "typeScriptVersion": "4.8"
222
222
  }