@types/node 22.5.2 → 22.5.3

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.
Files changed (5) hide show
  1. node/README.md +1 -1
  2. node/http.d.ts +5 -5
  3. node/http2.d.ts +254 -77
  4. node/https.d.ts +18 -14
  5. node/package.json +2 -2
node/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.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sun, 01 Sep 2024 12:10:27 GMT
11
+ * Last updated: Wed, 04 Sep 2024 00:28:08 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node/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<InstanceType<Request>>,
235
235
  > {
236
236
  /**
237
237
  * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
@@ -315,14 +315,14 @@ declare module "http" {
315
315
  }
316
316
  type RequestListener<
317
317
  Request extends typeof IncomingMessage = typeof IncomingMessage,
318
- Response extends typeof ServerResponse = typeof ServerResponse,
318
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
319
319
  > = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
320
320
  /**
321
321
  * @since v0.1.17
322
322
  */
323
323
  class Server<
324
324
  Request extends typeof IncomingMessage = typeof IncomingMessage,
325
- Response extends typeof ServerResponse = typeof ServerResponse,
325
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
326
326
  > extends NetServer {
327
327
  constructor(requestListener?: RequestListener<Request, Response>);
328
328
  constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
@@ -1553,11 +1553,11 @@ declare module "http" {
1553
1553
  */
1554
1554
  function createServer<
1555
1555
  Request extends typeof IncomingMessage = typeof IncomingMessage,
1556
- Response extends typeof ServerResponse = typeof ServerResponse,
1556
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
1557
1557
  >(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
1558
1558
  function createServer<
1559
1559
  Request extends typeof IncomingMessage = typeof IncomingMessage,
1560
- Response extends typeof ServerResponse = typeof ServerResponse,
1560
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
1561
1561
  >(
1562
1562
  options: ServerOptions<Request, Response>,
1563
1563
  requestListener?: RequestListener<Request, Response>,
node/http2.d.ts CHANGED
@@ -408,9 +408,9 @@ declare module "http2" {
408
408
  * });
409
409
  * ```
410
410
  *
411
- * Initiates a response. When the `options.waitForTrailers` option is set, the`'wantTrailers'` event will be emitted immediately after queuing the last chunk
412
- * of payload data to be sent. The `http2stream.sendTrailers()` method can then be
413
- * used to sent trailing 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.
414
414
  *
415
415
  * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
416
416
  * close when the final `DATA` frame is transmitted. User code must call either `http2stream.sendTrailers()` or `http2stream.close()` to close the `Http2Stream`.
@@ -459,8 +459,8 @@ declare module "http2" {
459
459
  *
460
460
  * The optional `options.statCheck` function may be specified to give user code
461
461
  * an opportunity to set additional content headers based on the `fs.Stat` details
462
- * of the given fd. If the `statCheck` function is provided, the `http2stream.respondWithFD()` method will perform an `fs.fstat()` call to
463
- * 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.
464
464
  *
465
465
  * The `offset` and `length` options may be used to limit the response to a
466
466
  * specific range subset. This can be used, for instance, to support HTTP Range
@@ -478,7 +478,8 @@ declare module "http2" {
478
478
  * header fields to the peer.
479
479
  *
480
480
  * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
481
- * 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`.
482
483
  *
483
484
  * ```js
484
485
  * const http2 = require('node:http2');
@@ -521,9 +522,9 @@ declare module "http2" {
521
522
  * an opportunity to set additional content headers based on the `fs.Stat` details
522
523
  * of the given file:
523
524
  *
524
- * 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
525
- * defined, then it will be called. Otherwise
526
- * 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.
527
528
  *
528
529
  * Example using a file path:
529
530
  *
@@ -677,7 +678,8 @@ declare module "http2" {
677
678
  */
678
679
  readonly encrypted?: boolean | undefined;
679
680
  /**
680
- * 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.
681
683
  * @since v8.4.0
682
684
  */
683
685
  readonly localSettings: Settings;
@@ -692,12 +694,14 @@ declare module "http2" {
692
694
  readonly originSet?: string[] | undefined;
693
695
  /**
694
696
  * Indicates whether the `Http2Session` is currently waiting for acknowledgment of
695
- * 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.
696
699
  * @since v8.4.0
697
700
  */
698
701
  readonly pendingSettingsAck: boolean;
699
702
  /**
700
- * 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.
701
705
  * @since v8.4.0
702
706
  */
703
707
  readonly remoteSettings: Settings;
@@ -1048,8 +1052,19 @@ declare module "http2" {
1048
1052
  export interface AlternativeServiceOptions {
1049
1053
  origin: number | string | url.URL;
1050
1054
  }
1051
- export interface ServerHttp2Session extends Http2Session {
1052
- 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
+ InstanceType<Http1Request>
1059
+ >,
1060
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1061
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1062
+ InstanceType<Http2Request>
1063
+ >,
1064
+ > extends Http2Session {
1065
+ readonly server:
1066
+ | Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>
1067
+ | Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
1053
1068
  /**
1054
1069
  * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.
1055
1070
  *
@@ -1144,17 +1159,30 @@ declare module "http2" {
1144
1159
  ): void;
1145
1160
  addListener(
1146
1161
  event: "connect",
1147
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1162
+ listener: (
1163
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1164
+ socket: net.Socket | tls.TLSSocket,
1165
+ ) => void,
1148
1166
  ): this;
1149
1167
  addListener(
1150
1168
  event: "stream",
1151
1169
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1152
1170
  ): this;
1153
1171
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1154
- emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
1172
+ emit(
1173
+ event: "connect",
1174
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1175
+ socket: net.Socket | tls.TLSSocket,
1176
+ ): boolean;
1155
1177
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1156
1178
  emit(event: string | symbol, ...args: any[]): boolean;
1157
- on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
1179
+ on(
1180
+ event: "connect",
1181
+ listener: (
1182
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1183
+ socket: net.Socket | tls.TLSSocket,
1184
+ ) => void,
1185
+ ): this;
1158
1186
  on(
1159
1187
  event: "stream",
1160
1188
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1162,7 +1190,10 @@ declare module "http2" {
1162
1190
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1163
1191
  once(
1164
1192
  event: "connect",
1165
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1193
+ listener: (
1194
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1195
+ socket: net.Socket | tls.TLSSocket,
1196
+ ) => void,
1166
1197
  ): this;
1167
1198
  once(
1168
1199
  event: "stream",
@@ -1171,7 +1202,10 @@ declare module "http2" {
1171
1202
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1172
1203
  prependListener(
1173
1204
  event: "connect",
1174
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1205
+ listener: (
1206
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1207
+ socket: net.Socket | tls.TLSSocket,
1208
+ ) => void,
1175
1209
  ): this;
1176
1210
  prependListener(
1177
1211
  event: "stream",
@@ -1180,7 +1214,10 @@ declare module "http2" {
1180
1214
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1181
1215
  prependOnceListener(
1182
1216
  event: "connect",
1183
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1217
+ listener: (
1218
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1219
+ socket: net.Socket | tls.TLSSocket,
1220
+ ) => void,
1184
1221
  ): this;
1185
1222
  prependOnceListener(
1186
1223
  event: "stream",
@@ -1213,16 +1250,52 @@ declare module "http2" {
1213
1250
  createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined;
1214
1251
  protocol?: "http:" | "https:" | undefined;
1215
1252
  }
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;
1253
+ export interface ServerSessionOptions<
1254
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1255
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1256
+ InstanceType<Http1Request>
1257
+ >,
1258
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1259
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1260
+ InstanceType<Http2Request>
1261
+ >,
1262
+ > extends SessionOptions {
1263
+ Http1IncomingMessage?: Http1Request | undefined;
1264
+ Http1ServerResponse?: Http1Response | undefined;
1265
+ Http2ServerRequest?: Http2Request | undefined;
1266
+ Http2ServerResponse?: Http2Response | undefined;
1221
1267
  }
1222
1268
  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 {
1269
+ export interface SecureServerSessionOptions<
1270
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1271
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1272
+ InstanceType<Http1Request>
1273
+ >,
1274
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1275
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1276
+ InstanceType<Http2Request>
1277
+ >,
1278
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response>, tls.TlsOptions {}
1279
+ export interface ServerOptions<
1280
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1281
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1282
+ InstanceType<Http1Request>
1283
+ >,
1284
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1285
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1286
+ InstanceType<Http2Request>
1287
+ >,
1288
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {}
1289
+ export interface SecureServerOptions<
1290
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1291
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1292
+ InstanceType<Http1Request>
1293
+ >,
1294
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1295
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1296
+ InstanceType<Http2Request>
1297
+ >,
1298
+ > extends SecureServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {
1226
1299
  allowHTTP1?: boolean | undefined;
1227
1300
  origins?: string[] | undefined;
1228
1301
  }
@@ -1234,16 +1307,28 @@ declare module "http2" {
1234
1307
  */
1235
1308
  updateSettings(settings: Settings): void;
1236
1309
  }
1237
- export interface Http2Server extends net.Server, HTTP2ServerCommon {
1310
+ export interface Http2Server<
1311
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1312
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1313
+ InstanceType<Http1Request>
1314
+ >,
1315
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1316
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1317
+ InstanceType<Http2Request>
1318
+ >,
1319
+ > extends net.Server, HTTP2ServerCommon {
1238
1320
  addListener(
1239
1321
  event: "checkContinue",
1240
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1322
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1241
1323
  ): this;
1242
1324
  addListener(
1243
1325
  event: "request",
1244
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1326
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1327
+ ): this;
1328
+ addListener(
1329
+ event: "session",
1330
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1245
1331
  ): this;
1246
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1247
1332
  addListener(event: "sessionError", listener: (err: Error) => void): this;
1248
1333
  addListener(
1249
1334
  event: "stream",
@@ -1251,19 +1336,32 @@ declare module "http2" {
1251
1336
  ): this;
1252
1337
  addListener(event: "timeout", listener: () => void): this;
1253
1338
  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;
1339
+ emit(
1340
+ event: "checkContinue",
1341
+ request: InstanceType<Http2Request>,
1342
+ response: InstanceType<Http2Response>,
1343
+ ): boolean;
1344
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1345
+ emit(
1346
+ event: "session",
1347
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1348
+ ): boolean;
1257
1349
  emit(event: "sessionError", err: Error): boolean;
1258
1350
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1259
1351
  emit(event: "timeout"): boolean;
1260
1352
  emit(event: string | symbol, ...args: any[]): boolean;
1261
1353
  on(
1262
1354
  event: "checkContinue",
1263
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1355
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1356
+ ): this;
1357
+ on(
1358
+ event: "request",
1359
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1360
+ ): this;
1361
+ on(
1362
+ event: "session",
1363
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1264
1364
  ): this;
1265
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1266
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1267
1365
  on(event: "sessionError", listener: (err: Error) => void): this;
1268
1366
  on(
1269
1367
  event: "stream",
@@ -1273,10 +1371,16 @@ declare module "http2" {
1273
1371
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1274
1372
  once(
1275
1373
  event: "checkContinue",
1276
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1374
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1375
+ ): this;
1376
+ once(
1377
+ event: "request",
1378
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1379
+ ): this;
1380
+ once(
1381
+ event: "session",
1382
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1277
1383
  ): this;
1278
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1279
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1280
1384
  once(event: "sessionError", listener: (err: Error) => void): this;
1281
1385
  once(
1282
1386
  event: "stream",
@@ -1286,13 +1390,16 @@ declare module "http2" {
1286
1390
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1287
1391
  prependListener(
1288
1392
  event: "checkContinue",
1289
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1393
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1290
1394
  ): this;
1291
1395
  prependListener(
1292
1396
  event: "request",
1293
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1397
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1398
+ ): this;
1399
+ prependListener(
1400
+ event: "session",
1401
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1294
1402
  ): this;
1295
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1296
1403
  prependListener(event: "sessionError", listener: (err: Error) => void): this;
1297
1404
  prependListener(
1298
1405
  event: "stream",
@@ -1302,13 +1409,16 @@ declare module "http2" {
1302
1409
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1303
1410
  prependOnceListener(
1304
1411
  event: "checkContinue",
1305
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1412
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1306
1413
  ): this;
1307
1414
  prependOnceListener(
1308
1415
  event: "request",
1309
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1416
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1417
+ ): this;
1418
+ prependOnceListener(
1419
+ event: "session",
1420
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1310
1421
  ): this;
1311
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1312
1422
  prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1313
1423
  prependOnceListener(
1314
1424
  event: "stream",
@@ -1317,16 +1427,28 @@ declare module "http2" {
1317
1427
  prependOnceListener(event: "timeout", listener: () => void): this;
1318
1428
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1319
1429
  }
1320
- export interface Http2SecureServer extends tls.Server, HTTP2ServerCommon {
1430
+ export interface Http2SecureServer<
1431
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1432
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
1433
+ InstanceType<Http1Request>
1434
+ >,
1435
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1436
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
1437
+ InstanceType<Http2Request>
1438
+ >,
1439
+ > extends tls.Server, HTTP2ServerCommon {
1321
1440
  addListener(
1322
1441
  event: "checkContinue",
1323
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1442
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1324
1443
  ): this;
1325
1444
  addListener(
1326
1445
  event: "request",
1327
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1446
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1447
+ ): this;
1448
+ addListener(
1449
+ event: "session",
1450
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1328
1451
  ): this;
1329
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1330
1452
  addListener(event: "sessionError", listener: (err: Error) => void): this;
1331
1453
  addListener(
1332
1454
  event: "stream",
@@ -1335,9 +1457,16 @@ declare module "http2" {
1335
1457
  addListener(event: "timeout", listener: () => void): this;
1336
1458
  addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1337
1459
  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;
1460
+ emit(
1461
+ event: "checkContinue",
1462
+ request: InstanceType<Http2Request>,
1463
+ response: InstanceType<Http2Response>,
1464
+ ): boolean;
1465
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1466
+ emit(
1467
+ event: "session",
1468
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1469
+ ): boolean;
1341
1470
  emit(event: "sessionError", err: Error): boolean;
1342
1471
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1343
1472
  emit(event: "timeout"): boolean;
@@ -1345,10 +1474,16 @@ declare module "http2" {
1345
1474
  emit(event: string | symbol, ...args: any[]): boolean;
1346
1475
  on(
1347
1476
  event: "checkContinue",
1348
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1477
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1478
+ ): this;
1479
+ on(
1480
+ event: "request",
1481
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1482
+ ): this;
1483
+ on(
1484
+ event: "session",
1485
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1349
1486
  ): this;
1350
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1351
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1352
1487
  on(event: "sessionError", listener: (err: Error) => void): this;
1353
1488
  on(
1354
1489
  event: "stream",
@@ -1359,10 +1494,16 @@ declare module "http2" {
1359
1494
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1360
1495
  once(
1361
1496
  event: "checkContinue",
1362
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1497
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1498
+ ): this;
1499
+ once(
1500
+ event: "request",
1501
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1502
+ ): this;
1503
+ once(
1504
+ event: "session",
1505
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1363
1506
  ): this;
1364
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1365
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1366
1507
  once(event: "sessionError", listener: (err: Error) => void): this;
1367
1508
  once(
1368
1509
  event: "stream",
@@ -1373,13 +1514,16 @@ declare module "http2" {
1373
1514
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1374
1515
  prependListener(
1375
1516
  event: "checkContinue",
1376
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1517
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1377
1518
  ): this;
1378
1519
  prependListener(
1379
1520
  event: "request",
1380
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1521
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1522
+ ): this;
1523
+ prependListener(
1524
+ event: "session",
1525
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1381
1526
  ): this;
1382
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1383
1527
  prependListener(event: "sessionError", listener: (err: Error) => void): this;
1384
1528
  prependListener(
1385
1529
  event: "stream",
@@ -1390,13 +1534,16 @@ declare module "http2" {
1390
1534
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1391
1535
  prependOnceListener(
1392
1536
  event: "checkContinue",
1393
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1537
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1394
1538
  ): this;
1395
1539
  prependOnceListener(
1396
1540
  event: "request",
1397
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1541
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1542
+ ): this;
1543
+ prependOnceListener(
1544
+ event: "session",
1545
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1398
1546
  ): this;
1399
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1400
1547
  prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1401
1548
  prependOnceListener(
1402
1549
  event: "stream",
@@ -1652,7 +1799,7 @@ declare module "http2" {
1652
1799
  * passed as the second parameter to the `'request'` event.
1653
1800
  * @since v8.4.0
1654
1801
  */
1655
- export class Http2ServerResponse extends stream.Writable {
1802
+ export class Http2ServerResponse<Request extends Http2ServerRequest = Http2ServerRequest> extends stream.Writable {
1656
1803
  constructor(stream: ServerHttp2Stream);
1657
1804
  /**
1658
1805
  * See `response.socket`.
@@ -1698,7 +1845,7 @@ declare module "http2" {
1698
1845
  * A reference to the original HTTP2 `request` object.
1699
1846
  * @since v15.7.0
1700
1847
  */
1701
- readonly req: Http2ServerRequest;
1848
+ readonly req: Request;
1702
1849
  /**
1703
1850
  * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but
1704
1851
  * applies getters, setters, and methods based on HTTP/2 logic.
@@ -2341,10 +2488,19 @@ declare module "http2" {
2341
2488
  export function createServer(
2342
2489
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2343
2490
  ): Http2Server;
2344
- export function createServer(
2345
- options: ServerOptions,
2346
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2347
- ): Http2Server;
2491
+ export function createServer<
2492
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2493
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
2494
+ InstanceType<Http1Request>
2495
+ >,
2496
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2497
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
2498
+ InstanceType<Http2Request>
2499
+ >,
2500
+ >(
2501
+ options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2502
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2503
+ ): Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>;
2348
2504
  /**
2349
2505
  * Returns a `tls.Server` instance that creates and manages `Http2Session` instances.
2350
2506
  *
@@ -2376,10 +2532,19 @@ declare module "http2" {
2376
2532
  export function createSecureServer(
2377
2533
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2378
2534
  ): Http2SecureServer;
2379
- export function createSecureServer(
2380
- options: SecureServerOptions,
2381
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2382
- ): Http2SecureServer;
2535
+ export function createSecureServer<
2536
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2537
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
2538
+ InstanceType<Http1Request>
2539
+ >,
2540
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2541
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
2542
+ InstanceType<Http2Request>
2543
+ >,
2544
+ >(
2545
+ options: SecureServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2546
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2547
+ ): Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
2383
2548
  /**
2384
2549
  * Returns a `ClientHttp2Session` instance.
2385
2550
  *
@@ -2411,7 +2576,19 @@ declare module "http2" {
2411
2576
  * @param options Any `{@link createServer}` options can be provided.
2412
2577
  * @since v20.12.0
2413
2578
  */
2414
- export function performServerHandshake(socket: stream.Duplex, options?: ServerOptions): ServerHttp2Session;
2579
+ export function performServerHandshake<
2580
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2581
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse<
2582
+ InstanceType<Http1Request>
2583
+ >,
2584
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2585
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse<
2586
+ InstanceType<Http2Request>
2587
+ >,
2588
+ >(
2589
+ socket: stream.Duplex,
2590
+ options?: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2591
+ ): ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>;
2415
2592
  }
2416
2593
  declare module "node:http2" {
2417
2594
  export * from "http2";
node/https.d.ts CHANGED
@@ -10,7 +10,9 @@ declare module "https" {
10
10
  import { URL } from "node:url";
11
11
  type ServerOptions<
12
12
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
13
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
13
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
14
+ InstanceType<Request>
15
+ >,
14
16
  > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
15
17
  type RequestOptions =
16
18
  & http.RequestOptions
@@ -34,7 +36,9 @@ declare module "https" {
34
36
  }
35
37
  interface Server<
36
38
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
37
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
39
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
40
+ InstanceType<Request>
41
+ >,
38
42
  > extends http.Server<Request, Response> {}
39
43
  /**
40
44
  * See `http.Server` for more information.
@@ -42,7 +46,9 @@ declare module "https" {
42
46
  */
43
47
  class Server<
44
48
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
45
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
49
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
50
+ InstanceType<Request>
51
+ >,
46
52
  > extends tls.Server {
47
53
  constructor(requestListener?: http.RequestListener<Request, Response>);
48
54
  constructor(
@@ -119,25 +125,19 @@ declare module "https" {
119
125
  emit(
120
126
  event: "checkContinue",
121
127
  req: InstanceType<Request>,
122
- res: InstanceType<Response> & {
123
- req: InstanceType<Request>;
124
- },
128
+ res: InstanceType<Response>,
125
129
  ): boolean;
126
130
  emit(
127
131
  event: "checkExpectation",
128
132
  req: InstanceType<Request>,
129
- res: InstanceType<Response> & {
130
- req: InstanceType<Request>;
131
- },
133
+ res: InstanceType<Response>,
132
134
  ): boolean;
133
135
  emit(event: "clientError", err: Error, socket: Duplex): boolean;
134
136
  emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
135
137
  emit(
136
138
  event: "request",
137
139
  req: InstanceType<Request>,
138
- res: InstanceType<Response> & {
139
- req: InstanceType<Request>;
140
- },
140
+ res: InstanceType<Response>,
141
141
  ): boolean;
142
142
  emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
143
143
  on(event: string, listener: (...args: any[]) => void): this;
@@ -312,11 +312,15 @@ declare module "https" {
312
312
  */
313
313
  function createServer<
314
314
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
315
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
315
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
316
+ InstanceType<Request>
317
+ >,
316
318
  >(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
317
319
  function createServer<
318
320
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
319
- Response extends typeof http.ServerResponse = typeof http.ServerResponse,
321
+ Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse<
322
+ InstanceType<Request>
323
+ >,
320
324
  >(
321
325
  options: ServerOptions<Request, Response>,
322
326
  requestListener?: http.RequestListener<Request, Response>,
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "22.5.2",
3
+ "version": "22.5.3",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -212,6 +212,6 @@
212
212
  "dependencies": {
213
213
  "undici-types": "~6.19.2"
214
214
  },
215
- "typesPublisherContentHash": "6ee9a11eba834031423800320320aa873d6bf2b6f33603c13a2aa9d90b3803ee",
215
+ "typesPublisherContentHash": "b838738b923117466b69f5c6125cb6df5c4b74969e34cc7a05ba64931ea00574",
216
216
  "typeScriptVersion": "4.8"
217
217
  }