@types/node 24.12.0 → 25.5.0

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 (98) hide show
  1. node v24.12/README.md → node/README.md +2 -2
  2. node v24.12/assert/strict.d.ts → node/assert/strict.d.ts +5 -11
  3. node v24.12/assert.d.ts → node/assert.d.ts +11 -171
  4. node v24.12/async_hooks.d.ts → node/async_hooks.d.ts +8 -8
  5. node v24.12/buffer.buffer.d.ts → node/buffer.buffer.d.ts +1 -7
  6. node v24.12/buffer.d.ts → node/buffer.d.ts +44 -168
  7. node v24.12/child_process.d.ts → node/child_process.d.ts +21 -64
  8. node/cluster.d.ts +486 -0
  9. node/console.d.ts +151 -0
  10. node v24.12/constants.d.ts → node/constants.d.ts +3 -4
  11. node v24.12/crypto.d.ts → node/crypto.d.ts +287 -1639
  12. node v24.12/dgram.d.ts → node/dgram.d.ts +15 -51
  13. node v24.12/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +4 -4
  14. node v24.12/dns/promises.d.ts → node/dns/promises.d.ts +3 -3
  15. node v24.12/dns.d.ts → node/dns.d.ts +131 -132
  16. node v24.12/domain.d.ts → node/domain.d.ts +13 -17
  17. node v24.12/events.d.ts → node/events.d.ts +866 -795
  18. node v24.12/fs/promises.d.ts → node/fs/promises.d.ts +7 -8
  19. node v24.12/fs.d.ts → node/fs.d.ts +419 -455
  20. node v24.12/globals.d.ts → node/globals.d.ts +6 -26
  21. node/globals.typedarray.d.ts +101 -0
  22. node v24.12/http.d.ts → node/http.d.ts +310 -276
  23. node v24.12/http2.d.ts → node/http2.d.ts +528 -804
  24. node v24.12/https.d.ts → node/https.d.ts +63 -243
  25. node v24.12/index.d.ts → node/index.d.ts +15 -1
  26. node/inspector/promises.d.ts +41 -0
  27. node v24.12/inspector.d.ts → node/inspector.d.ts +42 -50
  28. node v24.12/inspector.generated.d.ts → node/inspector.generated.d.ts +572 -417
  29. node v24.12/module.d.ts → node/module.d.ts +47 -195
  30. node v24.12/net.d.ts → node/net.d.ts +68 -189
  31. node v24.12/os.d.ts → node/os.d.ts +6 -6
  32. node v24.12/package.json → node/package.json +3 -3
  33. node/path/posix.d.ts +8 -0
  34. node/path/win32.d.ts +8 -0
  35. node/path.d.ts +187 -0
  36. node/perf_hooks.d.ts +643 -0
  37. node v24.12/process.d.ts → node/process.d.ts +219 -127
  38. node v24.12/punycode.d.ts → node/punycode.d.ts +5 -5
  39. node v24.12/querystring.d.ts → node/querystring.d.ts +4 -4
  40. node/quic.d.ts +910 -0
  41. node v24.12/readline/promises.d.ts → node/readline/promises.d.ts +3 -3
  42. node v24.12/readline.d.ts → node/readline.d.ts +68 -120
  43. node v24.12/repl.d.ts → node/repl.d.ts +75 -98
  44. node v24.12/sea.d.ts → node/sea.d.ts +1 -1
  45. node v24.12/sqlite.d.ts → node/sqlite.d.ts +137 -30
  46. node v24.12/stream/consumers.d.ts → node/stream/consumers.d.ts +10 -10
  47. node/stream/promises.d.ts +211 -0
  48. node/stream/web.d.ts +296 -0
  49. node v24.12/stream.d.ts → node/stream.d.ts +565 -478
  50. node v24.12/string_decoder.d.ts → node/string_decoder.d.ts +4 -4
  51. node/test/reporters.d.ts +96 -0
  52. node v24.12/test.d.ts → node/test.d.ts +134 -199
  53. node v24.12/timers/promises.d.ts → node/timers/promises.d.ts +4 -4
  54. node v24.12/timers.d.ts → node/timers.d.ts +4 -130
  55. node v24.12/tls.d.ts → node/tls.d.ts +109 -179
  56. node v24.12/trace_events.d.ts → node/trace_events.d.ts +9 -9
  57. node v24.12/ts5.6/buffer.buffer.d.ts → node/ts5.6/buffer.buffer.d.ts +1 -7
  58. node v24.12/ts5.6/index.d.ts → node/ts5.6/index.d.ts +15 -1
  59. node v24.12/ts5.7/index.d.ts → node/ts5.7/index.d.ts +15 -1
  60. node v24.12/tty.d.ts → node/tty.d.ts +58 -16
  61. node/url.d.ts +541 -0
  62. node/util/types.d.ts +558 -0
  63. node v24.12/util.d.ts → node/util.d.ts +150 -796
  64. node v24.12/v8.d.ts → node/v8.d.ts +31 -21
  65. node v24.12/vm.d.ts → node/vm.d.ts +43 -30
  66. node v24.12/wasi.d.ts → node/wasi.d.ts +4 -4
  67. node v24.12/web-globals/abortcontroller.d.ts → node/web-globals/abortcontroller.d.ts +27 -2
  68. node/web-globals/blob.d.ts +23 -0
  69. node/web-globals/console.d.ts +9 -0
  70. node v24.12/web-globals/crypto.d.ts → node/web-globals/crypto.d.ts +7 -0
  71. node/web-globals/encoding.d.ts +11 -0
  72. node v24.12/web-globals/events.d.ts → node/web-globals/events.d.ts +9 -0
  73. node v24.12/web-globals/fetch.d.ts → node/web-globals/fetch.d.ts +7 -0
  74. node/web-globals/importmeta.d.ts +13 -0
  75. node/web-globals/messaging.d.ts +23 -0
  76. node/web-globals/performance.d.ts +45 -0
  77. node/web-globals/streams.d.ts +115 -0
  78. node/web-globals/timers.d.ts +44 -0
  79. node/web-globals/url.d.ts +24 -0
  80. node v24.12/worker_threads.d.ts → node/worker_threads.d.ts +186 -363
  81. node v24.12/zlib.d.ts → node/zlib.d.ts +8 -71
  82. node v24.12/cluster.d.ts +0 -578
  83. node v24.12/console.d.ts +0 -453
  84. node v24.12/globals.typedarray.d.ts +0 -41
  85. node v24.12/path.d.ts +0 -200
  86. node v24.12/perf_hooks.d.ts +0 -1042
  87. node v24.12/stream/promises.d.ts +0 -90
  88. node v24.12/stream/web.d.ts +0 -573
  89. node v24.12/url.d.ts +0 -1057
  90. node v24.12/web-globals/streams.d.ts +0 -22
  91. {node v24.12 → node}/LICENSE +0 -0
  92. {node v24.12 → node}/compatibility/iterators.d.ts +0 -0
  93. {node v24.12 → node}/ts5.6/compatibility/float16array.d.ts +0 -0
  94. {node v24.12 → node}/ts5.6/globals.typedarray.d.ts +0 -0
  95. {node v24.12 → node}/ts5.7/compatibility/float16array.d.ts +0 -0
  96. {node v24.12 → node}/web-globals/domexception.d.ts +0 -0
  97. {node v24.12 → node}/web-globals/navigator.d.ts +0 -0
  98. {node v24.12 → node}/web-globals/storage.d.ts +0 -0
@@ -37,15 +37,15 @@
37
37
  * 'Host', 'example.com',
38
38
  * 'accepT', '*' ]
39
39
  * ```
40
- * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/http.js)
40
+ * @see [source](https://github.com/nodejs/node/blob/v25.x/lib/http.js)
41
41
  */
42
- declare module "http" {
42
+ declare module "node:http" {
43
43
  import { NonSharedBuffer } from "node:buffer";
44
- import * as stream from "node:stream";
45
- import { URL } from "node:url";
46
44
  import { LookupOptions } from "node:dns";
47
45
  import { EventEmitter } from "node:events";
48
- import { LookupFunction, Server as NetServer, Socket, TcpSocketConnectOpts } from "node:net";
46
+ import * as net from "node:net";
47
+ import * as stream from "node:stream";
48
+ import { URL } from "node:url";
49
49
  // incoming headers will never contain number
50
50
  interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
51
51
  accept?: string | undefined;
@@ -219,7 +219,7 @@ declare module "http" {
219
219
  insecureHTTPParser?: boolean | undefined;
220
220
  localAddress?: string | undefined;
221
221
  localPort?: number | undefined;
222
- lookup?: LookupFunction | undefined;
222
+ lookup?: net.LookupFunction | undefined;
223
223
  /**
224
224
  * @default 16384
225
225
  */
@@ -358,25 +358,39 @@ declare module "http" {
358
358
  */
359
359
  rejectNonStandardBodyWrites?: boolean | undefined;
360
360
  /**
361
- * If set to `true`, requests without `Content-Length` or `Transfer-Encoding` headers (indicating no body)
362
- * will be initialized with an already-ended body stream, so they will never emit any stream events
361
+ * If set to `true`, requests without `Content-Length`
362
+ * or `Transfer-Encoding` headers (indicating no body) will be initialized with an
363
+ * already-ended body stream, so they will never emit any stream events
363
364
  * (like `'data'` or `'end'`). You can use `req.readableEnded` to detect this case.
365
+ * @since v25.1.0
364
366
  * @default false
365
- * @since v24.12.0
366
367
  */
367
368
  optimizeEmptyRequests?: boolean | undefined;
368
369
  }
369
370
  type RequestListener<
370
371
  Request extends typeof IncomingMessage = typeof IncomingMessage,
371
372
  Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
372
- > = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
373
+ > = (request: InstanceType<Request>, response: InstanceType<Response> & { req: InstanceType<Request> }) => void;
374
+ interface ServerEventMap<
375
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
376
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
377
+ > extends net.ServerEventMap {
378
+ "checkContinue": Parameters<RequestListener<Request, Response>>;
379
+ "checkExpectation": Parameters<RequestListener<Request, Response>>;
380
+ "clientError": [exception: Error, socket: stream.Duplex];
381
+ "connect": [request: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer];
382
+ "connection": [socket: net.Socket];
383
+ "dropRequest": [request: InstanceType<Request>, socket: stream.Duplex];
384
+ "request": Parameters<RequestListener<Request, Response>>;
385
+ "upgrade": [req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer];
386
+ }
373
387
  /**
374
388
  * @since v0.1.17
375
389
  */
376
390
  class Server<
377
391
  Request extends typeof IncomingMessage = typeof IncomingMessage,
378
392
  Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
379
- > extends NetServer {
393
+ > extends net.Server {
380
394
  constructor(requestListener?: RequestListener<Request, Response>);
381
395
  constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
382
396
  /**
@@ -393,8 +407,8 @@ declare module "http" {
393
407
  * @since v0.9.12
394
408
  * @param [msecs=0 (no timeout)]
395
409
  */
396
- setTimeout(msecs?: number, callback?: (socket: Socket) => void): this;
397
- setTimeout(callback: (socket: Socket) => void): this;
410
+ setTimeout(msecs?: number, callback?: (socket: net.Socket) => void): this;
411
+ setTimeout(callback: (socket: net.Socket) => void): this;
398
412
  /**
399
413
  * Limits maximum incoming headers count. If set to 0, no limit will be applied.
400
414
  * @since v0.7.0
@@ -494,126 +508,64 @@ declare module "http" {
494
508
  * @since v18.2.0
495
509
  */
496
510
  closeIdleConnections(): void;
497
- addListener(event: string, listener: (...args: any[]) => void): this;
498
- addListener(event: "close", listener: () => void): this;
499
- addListener(event: "connection", listener: (socket: Socket) => void): this;
500
- addListener(event: "error", listener: (err: Error) => void): this;
501
- addListener(event: "listening", listener: () => void): this;
502
- addListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
503
- addListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
504
- addListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
505
- addListener(
506
- event: "connect",
507
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
508
- ): this;
509
- addListener(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
510
- addListener(event: "request", listener: RequestListener<Request, Response>): this;
511
- addListener(
512
- event: "upgrade",
513
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
514
- ): this;
515
- emit(event: string, ...args: any[]): boolean;
516
- emit(event: "close"): boolean;
517
- emit(event: "connection", socket: Socket): boolean;
518
- emit(event: "error", err: Error): boolean;
519
- emit(event: "listening"): boolean;
520
- emit(
521
- event: "checkContinue",
522
- req: InstanceType<Request>,
523
- res: InstanceType<Response> & { req: InstanceType<Request> },
524
- ): boolean;
525
- emit(
526
- event: "checkExpectation",
527
- req: InstanceType<Request>,
528
- res: InstanceType<Response> & { req: InstanceType<Request> },
529
- ): boolean;
530
- emit(event: "clientError", err: Error, socket: stream.Duplex): boolean;
531
- emit(event: "connect", req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer): boolean;
532
- emit(event: "dropRequest", req: InstanceType<Request>, socket: stream.Duplex): boolean;
533
- emit(
534
- event: "request",
535
- req: InstanceType<Request>,
536
- res: InstanceType<Response> & { req: InstanceType<Request> },
537
- ): boolean;
538
- emit(event: "upgrade", req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer): boolean;
539
- on(event: string, listener: (...args: any[]) => void): this;
540
- on(event: "close", listener: () => void): this;
541
- on(event: "connection", listener: (socket: Socket) => void): this;
542
- on(event: "error", listener: (err: Error) => void): this;
543
- on(event: "listening", listener: () => void): this;
544
- on(event: "checkContinue", listener: RequestListener<Request, Response>): this;
545
- on(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
546
- on(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
547
- on(
548
- event: "connect",
549
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
550
- ): this;
551
- on(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
552
- on(event: "request", listener: RequestListener<Request, Response>): this;
553
- on(
554
- event: "upgrade",
555
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
511
+ // #region InternalEventEmitter
512
+ addListener<E extends keyof ServerEventMap>(
513
+ eventName: E,
514
+ listener: (...args: ServerEventMap<Request, Response>[E]) => void,
556
515
  ): this;
557
- once(event: string, listener: (...args: any[]) => void): this;
558
- once(event: "close", listener: () => void): this;
559
- once(event: "connection", listener: (socket: Socket) => void): this;
560
- once(event: "error", listener: (err: Error) => void): this;
561
- once(event: "listening", listener: () => void): this;
562
- once(event: "checkContinue", listener: RequestListener<Request, Response>): this;
563
- once(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
564
- once(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
565
- once(
566
- event: "connect",
567
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
516
+ addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
517
+ emit<E extends keyof ServerEventMap>(eventName: E, ...args: ServerEventMap<Request, Response>[E]): boolean;
518
+ emit(eventName: string | symbol, ...args: any[]): boolean;
519
+ listenerCount<E extends keyof ServerEventMap>(
520
+ eventName: E,
521
+ listener?: (...args: ServerEventMap<Request, Response>[E]) => void,
522
+ ): number;
523
+ listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
524
+ listeners<E extends keyof ServerEventMap>(
525
+ eventName: E,
526
+ ): ((...args: ServerEventMap<Request, Response>[E]) => void)[];
527
+ listeners(eventName: string | symbol): ((...args: any[]) => void)[];
528
+ off<E extends keyof ServerEventMap>(
529
+ eventName: E,
530
+ listener: (...args: ServerEventMap<Request, Response>[E]) => void,
568
531
  ): this;
569
- once(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
570
- once(event: "request", listener: RequestListener<Request, Response>): this;
571
- once(
572
- event: "upgrade",
573
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
532
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
533
+ on<E extends keyof ServerEventMap>(
534
+ eventName: E,
535
+ listener: (...args: ServerEventMap<Request, Response>[E]) => void,
574
536
  ): this;
575
- prependListener(event: string, listener: (...args: any[]) => void): this;
576
- prependListener(event: "close", listener: () => void): this;
577
- prependListener(event: "connection", listener: (socket: Socket) => void): this;
578
- prependListener(event: "error", listener: (err: Error) => void): this;
579
- prependListener(event: "listening", listener: () => void): this;
580
- prependListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
581
- prependListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
582
- prependListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
583
- prependListener(
584
- event: "connect",
585
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
537
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
538
+ once<E extends keyof ServerEventMap>(
539
+ eventName: E,
540
+ listener: (...args: ServerEventMap<Request, Response>[E]) => void,
586
541
  ): this;
587
- prependListener(
588
- event: "dropRequest",
589
- listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
542
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
543
+ prependListener<E extends keyof ServerEventMap>(
544
+ eventName: E,
545
+ listener: (...args: ServerEventMap<Request, Response>[E]) => void,
590
546
  ): this;
591
- prependListener(event: "request", listener: RequestListener<Request, Response>): this;
592
- prependListener(
593
- event: "upgrade",
594
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
547
+ prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
548
+ prependOnceListener<E extends keyof ServerEventMap>(
549
+ eventName: E,
550
+ listener: (...args: ServerEventMap<Request, Response>[E]) => void,
595
551
  ): this;
596
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
597
- prependOnceListener(event: "close", listener: () => void): this;
598
- prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
599
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
600
- prependOnceListener(event: "listening", listener: () => void): this;
601
- prependOnceListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
602
- prependOnceListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
603
- prependOnceListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
604
- prependOnceListener(
605
- event: "connect",
606
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
607
- ): this;
608
- prependOnceListener(
609
- event: "dropRequest",
610
- listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
611
- ): this;
612
- prependOnceListener(event: "request", listener: RequestListener<Request, Response>): this;
613
- prependOnceListener(
614
- event: "upgrade",
615
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
552
+ prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
553
+ rawListeners<E extends keyof ServerEventMap>(
554
+ eventName: E,
555
+ ): ((...args: ServerEventMap<Request, Response>[E]) => void)[];
556
+ rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
557
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
558
+ removeAllListeners<E extends keyof ServerEventMap>(eventName?: E): this;
559
+ removeAllListeners(eventName?: string | symbol): this;
560
+ removeListener<E extends keyof ServerEventMap>(
561
+ eventName: E,
562
+ listener: (...args: ServerEventMap<Request, Response>[E]) => void,
616
563
  ): this;
564
+ removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
565
+ // #endregion
566
+ }
567
+ interface OutgoingMessageEventMap extends stream.WritableEventMap {
568
+ "prefinish": [];
617
569
  }
618
570
  /**
619
571
  * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from
@@ -621,6 +573,7 @@ declare module "http" {
621
573
  * @since v0.1.17
622
574
  */
623
575
  class OutgoingMessage<Request extends IncomingMessage = IncomingMessage> extends stream.Writable {
576
+ constructor();
624
577
  readonly req: Request;
625
578
  chunkedEncoding: boolean;
626
579
  shouldKeepAlive: boolean;
@@ -640,7 +593,7 @@ declare module "http" {
640
593
  * @since v0.3.0
641
594
  * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead.
642
595
  */
643
- readonly connection: Socket | null;
596
+ readonly connection: net.Socket | null;
644
597
  /**
645
598
  * Reference to the underlying socket. Usually, users will not want to access
646
599
  * this property.
@@ -648,8 +601,7 @@ declare module "http" {
648
601
  * After calling `outgoingMessage.end()`, this property will be nulled.
649
602
  * @since v0.3.0
650
603
  */
651
- readonly socket: Socket | null;
652
- constructor();
604
+ readonly socket: net.Socket | null;
653
605
  /**
654
606
  * Once a socket is associated with the message and is connected, `socket.setTimeout()` will be called with `msecs` as the first parameter.
655
607
  * @since v0.9.12
@@ -807,6 +759,61 @@ declare module "http" {
807
759
  * @since v1.6.0
808
760
  */
809
761
  flushHeaders(): void;
762
+ // #region InternalEventEmitter
763
+ addListener<E extends keyof OutgoingMessageEventMap>(
764
+ eventName: E,
765
+ listener: (...args: OutgoingMessageEventMap[E]) => void,
766
+ ): this;
767
+ addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
768
+ emit<E extends keyof OutgoingMessageEventMap>(eventName: E, ...args: OutgoingMessageEventMap[E]): boolean;
769
+ emit(eventName: string | symbol, ...args: any[]): boolean;
770
+ listenerCount<E extends keyof OutgoingMessageEventMap>(
771
+ eventName: E,
772
+ listener?: (...args: OutgoingMessageEventMap[E]) => void,
773
+ ): number;
774
+ listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
775
+ listeners<E extends keyof OutgoingMessageEventMap>(
776
+ eventName: E,
777
+ ): ((...args: OutgoingMessageEventMap[E]) => void)[];
778
+ listeners(eventName: string | symbol): ((...args: any[]) => void)[];
779
+ off<E extends keyof OutgoingMessageEventMap>(
780
+ eventName: E,
781
+ listener: (...args: OutgoingMessageEventMap[E]) => void,
782
+ ): this;
783
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
784
+ on<E extends keyof OutgoingMessageEventMap>(
785
+ eventName: E,
786
+ listener: (...args: OutgoingMessageEventMap[E]) => void,
787
+ ): this;
788
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
789
+ once<E extends keyof OutgoingMessageEventMap>(
790
+ eventName: E,
791
+ listener: (...args: OutgoingMessageEventMap[E]) => void,
792
+ ): this;
793
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
794
+ prependListener<E extends keyof OutgoingMessageEventMap>(
795
+ eventName: E,
796
+ listener: (...args: OutgoingMessageEventMap[E]) => void,
797
+ ): this;
798
+ prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
799
+ prependOnceListener<E extends keyof OutgoingMessageEventMap>(
800
+ eventName: E,
801
+ listener: (...args: OutgoingMessageEventMap[E]) => void,
802
+ ): this;
803
+ prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
804
+ rawListeners<E extends keyof OutgoingMessageEventMap>(
805
+ eventName: E,
806
+ ): ((...args: OutgoingMessageEventMap[E]) => void)[];
807
+ rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
808
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
809
+ removeAllListeners<E extends keyof OutgoingMessageEventMap>(eventName?: E): this;
810
+ removeAllListeners(eventName?: string | symbol): this;
811
+ removeListener<E extends keyof OutgoingMessageEventMap>(
812
+ eventName: E,
813
+ listener: (...args: OutgoingMessageEventMap[E]) => void,
814
+ ): this;
815
+ removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
816
+ // #endregion
810
817
  }
811
818
  /**
812
819
  * This object is created internally by an HTTP server, not by the user. It is
@@ -851,8 +858,8 @@ declare module "http" {
851
858
  */
852
859
  strictContentLength: boolean;
853
860
  constructor(req: Request);
854
- assignSocket(socket: Socket): void;
855
- detachSocket(socket: Socket): void;
861
+ assignSocket(socket: net.Socket): void;
862
+ detachSocket(socket: net.Socket): void;
856
863
  /**
857
864
  * Sends an HTTP/1.1 100 Continue message to the client, indicating that
858
865
  * the request body should be sent. See the `'checkContinue'` event on `Server`.
@@ -964,14 +971,25 @@ declare module "http" {
964
971
  writeProcessing(callback?: () => void): void;
965
972
  }
966
973
  interface InformationEvent {
967
- statusCode: number;
968
- statusMessage: string;
969
974
  httpVersion: string;
970
975
  httpVersionMajor: number;
971
976
  httpVersionMinor: number;
977
+ statusCode: number;
978
+ statusMessage: string;
972
979
  headers: IncomingHttpHeaders;
973
980
  rawHeaders: string[];
974
981
  }
982
+ interface ClientRequestEventMap extends stream.WritableEventMap {
983
+ /** @deprecated Listen for the `'close'` event instead. */
984
+ "abort": [];
985
+ "connect": [response: IncomingMessage, socket: net.Socket, head: NonSharedBuffer];
986
+ "continue": [];
987
+ "information": [info: InformationEvent];
988
+ "response": [response: IncomingMessage];
989
+ "socket": [socket: net.Socket];
990
+ "timeout": [];
991
+ "upgrade": [response: IncomingMessage, socket: net.Socket, head: NonSharedBuffer];
992
+ }
975
993
  /**
976
994
  * This object is created internally and returned from {@link request}. It
977
995
  * represents an _in-progress_ request whose header has already been queued. The
@@ -1095,7 +1113,7 @@ declare module "http" {
1095
1113
  * @deprecated Since v14.1.0,v13.14.0 - Use `destroy` instead.
1096
1114
  */
1097
1115
  abort(): void;
1098
- onSocket(socket: Socket): void;
1116
+ onSocket(socket: net.Socket): void;
1099
1117
  /**
1100
1118
  * Once a socket is assigned to this request and is connected `socket.setTimeout()` will be called.
1101
1119
  * @since v0.5.9
@@ -1127,126 +1145,63 @@ declare module "http" {
1127
1145
  * @since v15.13.0, v14.17.0
1128
1146
  */
1129
1147
  getRawHeaderNames(): string[];
1130
- /**
1131
- * @deprecated
1132
- */
1133
- addListener(event: "abort", listener: () => void): this;
1134
- addListener(
1135
- event: "connect",
1136
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1137
- ): this;
1138
- addListener(event: "continue", listener: () => void): this;
1139
- addListener(event: "information", listener: (info: InformationEvent) => void): this;
1140
- addListener(event: "response", listener: (response: IncomingMessage) => void): this;
1141
- addListener(event: "socket", listener: (socket: Socket) => void): this;
1142
- addListener(event: "timeout", listener: () => void): this;
1143
- addListener(
1144
- event: "upgrade",
1145
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1148
+ // #region InternalEventEmitter
1149
+ addListener<E extends keyof ClientRequestEventMap>(
1150
+ eventName: E,
1151
+ listener: (...args: ClientRequestEventMap[E]) => void,
1146
1152
  ): this;
1147
- addListener(event: "close", listener: () => void): this;
1148
- addListener(event: "drain", listener: () => void): this;
1149
- addListener(event: "error", listener: (err: Error) => void): this;
1150
- addListener(event: "finish", listener: () => void): this;
1151
- addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1152
- addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1153
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1154
- /**
1155
- * @deprecated
1156
- */
1157
- on(event: "abort", listener: () => void): this;
1158
- on(
1159
- event: "connect",
1160
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1153
+ addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
1154
+ emit<E extends keyof ClientRequestEventMap>(eventName: E, ...args: ClientRequestEventMap[E]): boolean;
1155
+ emit(eventName: string | symbol, ...args: any[]): boolean;
1156
+ listenerCount<E extends keyof ClientRequestEventMap>(
1157
+ eventName: E,
1158
+ listener?: (...args: ClientRequestEventMap[E]) => void,
1159
+ ): number;
1160
+ listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
1161
+ listeners<E extends keyof ClientRequestEventMap>(eventName: E): ((...args: ClientRequestEventMap[E]) => void)[];
1162
+ listeners(eventName: string | symbol): ((...args: any[]) => void)[];
1163
+ off<E extends keyof ClientRequestEventMap>(
1164
+ eventName: E,
1165
+ listener: (...args: ClientRequestEventMap[E]) => void,
1161
1166
  ): this;
1162
- on(event: "continue", listener: () => void): this;
1163
- on(event: "information", listener: (info: InformationEvent) => void): this;
1164
- on(event: "response", listener: (response: IncomingMessage) => void): this;
1165
- on(event: "socket", listener: (socket: Socket) => void): this;
1166
- on(event: "timeout", listener: () => void): this;
1167
- on(
1168
- event: "upgrade",
1169
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1167
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
1168
+ on<E extends keyof ClientRequestEventMap>(
1169
+ eventName: E,
1170
+ listener: (...args: ClientRequestEventMap[E]) => void,
1170
1171
  ): this;
1171
- on(event: "close", listener: () => void): this;
1172
- on(event: "drain", listener: () => void): this;
1173
- on(event: "error", listener: (err: Error) => void): this;
1174
- on(event: "finish", listener: () => void): this;
1175
- on(event: "pipe", listener: (src: stream.Readable) => void): this;
1176
- on(event: "unpipe", listener: (src: stream.Readable) => void): this;
1177
- on(event: string | symbol, listener: (...args: any[]) => void): this;
1178
- /**
1179
- * @deprecated
1180
- */
1181
- once(event: "abort", listener: () => void): this;
1182
- once(
1183
- event: "connect",
1184
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1172
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
1173
+ once<E extends keyof ClientRequestEventMap>(
1174
+ eventName: E,
1175
+ listener: (...args: ClientRequestEventMap[E]) => void,
1185
1176
  ): this;
1186
- once(event: "continue", listener: () => void): this;
1187
- once(event: "information", listener: (info: InformationEvent) => void): this;
1188
- once(event: "response", listener: (response: IncomingMessage) => void): this;
1189
- once(event: "socket", listener: (socket: Socket) => void): this;
1190
- once(event: "timeout", listener: () => void): this;
1191
- once(
1192
- event: "upgrade",
1193
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1177
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
1178
+ prependListener<E extends keyof ClientRequestEventMap>(
1179
+ eventName: E,
1180
+ listener: (...args: ClientRequestEventMap[E]) => void,
1194
1181
  ): this;
1195
- once(event: "close", listener: () => void): this;
1196
- once(event: "drain", listener: () => void): this;
1197
- once(event: "error", listener: (err: Error) => void): this;
1198
- once(event: "finish", listener: () => void): this;
1199
- once(event: "pipe", listener: (src: stream.Readable) => void): this;
1200
- once(event: "unpipe", listener: (src: stream.Readable) => void): this;
1201
- once(event: string | symbol, listener: (...args: any[]) => void): this;
1202
- /**
1203
- * @deprecated
1204
- */
1205
- prependListener(event: "abort", listener: () => void): this;
1206
- prependListener(
1207
- event: "connect",
1208
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1182
+ prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
1183
+ prependOnceListener<E extends keyof ClientRequestEventMap>(
1184
+ eventName: E,
1185
+ listener: (...args: ClientRequestEventMap[E]) => void,
1209
1186
  ): this;
1210
- prependListener(event: "continue", listener: () => void): this;
1211
- prependListener(event: "information", listener: (info: InformationEvent) => void): this;
1212
- prependListener(event: "response", listener: (response: IncomingMessage) => void): this;
1213
- prependListener(event: "socket", listener: (socket: Socket) => void): this;
1214
- prependListener(event: "timeout", listener: () => void): this;
1215
- prependListener(
1216
- event: "upgrade",
1217
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1187
+ prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
1188
+ rawListeners<E extends keyof ClientRequestEventMap>(
1189
+ eventName: E,
1190
+ ): ((...args: ClientRequestEventMap[E]) => void)[];
1191
+ rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
1192
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
1193
+ removeAllListeners<E extends keyof ClientRequestEventMap>(eventName?: E): this;
1194
+ removeAllListeners(eventName?: string | symbol): this;
1195
+ removeListener<E extends keyof ClientRequestEventMap>(
1196
+ eventName: E,
1197
+ listener: (...args: ClientRequestEventMap[E]) => void,
1218
1198
  ): this;
1219
- prependListener(event: "close", listener: () => void): this;
1220
- prependListener(event: "drain", listener: () => void): this;
1221
- prependListener(event: "error", listener: (err: Error) => void): this;
1222
- prependListener(event: "finish", listener: () => void): this;
1223
- prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1224
- prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1225
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1226
- /**
1227
- * @deprecated
1228
- */
1229
- prependOnceListener(event: "abort", listener: () => void): this;
1230
- prependOnceListener(
1231
- event: "connect",
1232
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1233
- ): this;
1234
- prependOnceListener(event: "continue", listener: () => void): this;
1235
- prependOnceListener(event: "information", listener: (info: InformationEvent) => void): this;
1236
- prependOnceListener(event: "response", listener: (response: IncomingMessage) => void): this;
1237
- prependOnceListener(event: "socket", listener: (socket: Socket) => void): this;
1238
- prependOnceListener(event: "timeout", listener: () => void): this;
1239
- prependOnceListener(
1240
- event: "upgrade",
1241
- listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1242
- ): this;
1243
- prependOnceListener(event: "close", listener: () => void): this;
1244
- prependOnceListener(event: "drain", listener: () => void): this;
1245
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
1246
- prependOnceListener(event: "finish", listener: () => void): this;
1247
- prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1248
- prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1249
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1199
+ removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
1200
+ // #endregion
1201
+ }
1202
+ interface IncomingMessageEventMap extends stream.ReadableEventMap {
1203
+ /** @deprecated Listen for `'close'` event instead. */
1204
+ "aborted": [];
1250
1205
  }
1251
1206
  /**
1252
1207
  * An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to
@@ -1259,7 +1214,7 @@ declare module "http" {
1259
1214
  * @since v0.1.17
1260
1215
  */
1261
1216
  class IncomingMessage extends stream.Readable {
1262
- constructor(socket: Socket);
1217
+ constructor(socket: net.Socket);
1263
1218
  /**
1264
1219
  * The `message.aborted` property will be `true` if the request has
1265
1220
  * been aborted.
@@ -1307,7 +1262,7 @@ declare module "http" {
1307
1262
  * @since v0.1.90
1308
1263
  * @deprecated Since v16.0.0 - Use `socket`.
1309
1264
  */
1310
- connection: Socket;
1265
+ connection: net.Socket;
1311
1266
  /**
1312
1267
  * The `net.Socket` object associated with the connection.
1313
1268
  *
@@ -1319,7 +1274,7 @@ declare module "http" {
1319
1274
  * type other than `net.Socket` or internally nulled.
1320
1275
  * @since v0.3.0
1321
1276
  */
1322
- socket: Socket;
1277
+ socket: net.Socket;
1323
1278
  /**
1324
1279
  * The request/response headers object.
1325
1280
  *
@@ -1481,6 +1436,61 @@ declare module "http" {
1481
1436
  * @since v0.3.0
1482
1437
  */
1483
1438
  destroy(error?: Error): this;
1439
+ // #region InternalEventEmitter
1440
+ addListener<E extends keyof IncomingMessageEventMap>(
1441
+ eventName: E,
1442
+ listener: (...args: IncomingMessageEventMap[E]) => void,
1443
+ ): this;
1444
+ addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
1445
+ emit<E extends keyof IncomingMessageEventMap>(eventName: E, ...args: IncomingMessageEventMap[E]): boolean;
1446
+ emit(eventName: string | symbol, ...args: any[]): boolean;
1447
+ listenerCount<E extends keyof IncomingMessageEventMap>(
1448
+ eventName: E,
1449
+ listener?: (...args: IncomingMessageEventMap[E]) => void,
1450
+ ): number;
1451
+ listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
1452
+ listeners<E extends keyof IncomingMessageEventMap>(
1453
+ eventName: E,
1454
+ ): ((...args: IncomingMessageEventMap[E]) => void)[];
1455
+ listeners(eventName: string | symbol): ((...args: any[]) => void)[];
1456
+ off<E extends keyof IncomingMessageEventMap>(
1457
+ eventName: E,
1458
+ listener: (...args: IncomingMessageEventMap[E]) => void,
1459
+ ): this;
1460
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
1461
+ on<E extends keyof IncomingMessageEventMap>(
1462
+ eventName: E,
1463
+ listener: (...args: IncomingMessageEventMap[E]) => void,
1464
+ ): this;
1465
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
1466
+ once<E extends keyof IncomingMessageEventMap>(
1467
+ eventName: E,
1468
+ listener: (...args: IncomingMessageEventMap[E]) => void,
1469
+ ): this;
1470
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
1471
+ prependListener<E extends keyof IncomingMessageEventMap>(
1472
+ eventName: E,
1473
+ listener: (...args: IncomingMessageEventMap[E]) => void,
1474
+ ): this;
1475
+ prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
1476
+ prependOnceListener<E extends keyof IncomingMessageEventMap>(
1477
+ eventName: E,
1478
+ listener: (...args: IncomingMessageEventMap[E]) => void,
1479
+ ): this;
1480
+ prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
1481
+ rawListeners<E extends keyof IncomingMessageEventMap>(
1482
+ eventName: E,
1483
+ ): ((...args: IncomingMessageEventMap[E]) => void)[];
1484
+ rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
1485
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
1486
+ removeAllListeners<E extends keyof IncomingMessageEventMap>(eventName?: E): this;
1487
+ removeAllListeners(eventName?: string | symbol): this;
1488
+ removeListener<E extends keyof IncomingMessageEventMap>(
1489
+ eventName: E,
1490
+ listener: (...args: IncomingMessageEventMap[E]) => void,
1491
+ ): this;
1492
+ removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
1493
+ // #endregion
1484
1494
  }
1485
1495
  interface ProxyEnv extends NodeJS.ProcessEnv {
1486
1496
  HTTP_PROXY?: string | undefined;
@@ -1490,7 +1500,7 @@ declare module "http" {
1490
1500
  https_proxy?: string | undefined;
1491
1501
  no_proxy?: string | undefined;
1492
1502
  }
1493
- interface AgentOptions extends NodeJS.PartialOptions<TcpSocketConnectOpts> {
1503
+ interface AgentOptions extends NodeJS.PartialOptions<net.TcpSocketConnectOpts> {
1494
1504
  /**
1495
1505
  * Keep sockets around in a pool to be used by other requests in the future. Default = false
1496
1506
  */
@@ -1533,7 +1543,7 @@ declare module "http" {
1533
1543
  scheduling?: "fifo" | "lifo" | undefined;
1534
1544
  /**
1535
1545
  * Environment variables for proxy configuration. See
1536
- * [Built-in Proxy Support](https://nodejs.org/docs/latest-v24.x/api/http.html#built-in-proxy-support) for details.
1546
+ * [Built-in Proxy Support](https://nodejs.org/docs/latest-v25.x/api/http.html#built-in-proxy-support) for details.
1537
1547
  * @since v24.5.0
1538
1548
  */
1539
1549
  proxyEnv?: ProxyEnv | undefined;
@@ -1602,7 +1612,7 @@ declare module "http" {
1602
1612
  * });
1603
1613
  * ```
1604
1614
  *
1605
- * `options` in [`socket.connect()`](https://nodejs.org/docs/latest-v24.x/api/net.html#socketconnectoptions-connectlistener) are also supported.
1615
+ * `options` in [`socket.connect()`](https://nodejs.org/docs/latest-v25.x/api/net.html#socketconnectoptions-connectlistener) are also supported.
1606
1616
  *
1607
1617
  * To configure any of them, a custom {@link Agent} instance must be created.
1608
1618
  *
@@ -1642,13 +1652,13 @@ declare module "http" {
1642
1652
  * removed from the array on `'timeout'`.
1643
1653
  * @since v0.11.4
1644
1654
  */
1645
- readonly freeSockets: NodeJS.ReadOnlyDict<Socket[]>;
1655
+ readonly freeSockets: NodeJS.ReadOnlyDict<net.Socket[]>;
1646
1656
  /**
1647
1657
  * An object which contains arrays of sockets currently in use by the
1648
1658
  * agent. Do not modify.
1649
1659
  * @since v0.3.6
1650
1660
  */
1651
- readonly sockets: NodeJS.ReadOnlyDict<Socket[]>;
1661
+ readonly sockets: NodeJS.ReadOnlyDict<net.Socket[]>;
1652
1662
  /**
1653
1663
  * An object which contains queues of requests that have not yet been assigned to
1654
1664
  * sockets. Do not modify.
@@ -1670,31 +1680,34 @@ declare module "http" {
1670
1680
  /**
1671
1681
  * Produces a socket/stream to be used for HTTP requests.
1672
1682
  *
1673
- * By default, this function behaves identically to `net.createConnection()`, synchronously
1674
- * returning the created socket. The optional `callback` parameter in the signature is not
1675
- * used by this default implementation.
1683
+ * By default, this function behaves identically to `net.createConnection()`,
1684
+ * synchronously returning the created socket. The optional `callback` parameter in the
1685
+ * signature is **not** used by this default implementation.
1676
1686
  *
1677
1687
  * However, custom agents may override this method to provide greater flexibility,
1678
1688
  * for example, to create sockets asynchronously. When overriding `createConnection`:
1679
1689
  *
1680
- * 1. **Synchronous socket creation**: The overriding method can return the socket/stream directly.
1681
- * 2. **Asynchronous socket creation**: The overriding method can accept the `callback` and pass
1682
- * the created socket/stream to it (e.g., `callback(null, newSocket)`). If an error occurs during
1683
- * socket creation, it should be passed as the first argument to the `callback` (e.g., `callback(err)`).
1690
+ * 1. **Synchronous socket creation**: The overriding method can return the
1691
+ * socket/stream directly.
1692
+ * 2. **Asynchronous socket creation**: The overriding method can accept the `callback`
1693
+ * and pass the created socket/stream to it (e.g., `callback(null, newSocket)`).
1694
+ * If an error occurs during socket creation, it should be passed as the first
1695
+ * argument to the `callback` (e.g., `callback(err)`).
1684
1696
  *
1685
- * The agent will call the provided `createConnection` function with `options` and this internal
1686
- * `callback`. The `callback` provided by the agent has a signature of `(err, stream)`.
1697
+ * The agent will call the provided `createConnection` function with `options` and
1698
+ * this internal `callback`. The `callback` provided by the agent has a signature
1699
+ * of `(err, stream)`.
1687
1700
  * @since v0.11.4
1688
- * @param options Options containing connection details. Check `net.createConnection()`
1689
- * for the format of the options. For custom agents, this object is passed
1690
- * to the custom `createConnection` function.
1691
- * @param callback (Optional, primarily for custom agents) A function to be called by a custom
1692
- * `createConnection` implementation when the socket is created, especially for
1693
- * asynchronous operations.
1694
- * @returns `stream.Duplex` The created socket. This is returned by the default implementation
1695
- * or by a custom synchronous `createConnection` implementation. If a
1696
- * custom `createConnection` uses the `callback` for asynchronous operation,
1697
- * this return value might not be the primary way to obtain the socket.
1701
+ * @param options Options containing connection details. Check
1702
+ * `net.createConnection` for the format of the options. For custom agents,
1703
+ * this object is passed to the custom `createConnection` function.
1704
+ * @param callback (Optional, primarily for custom agents) A function to be
1705
+ * called by a custom `createConnection` implementation when the socket is
1706
+ * created, especially for asynchronous operations.
1707
+ * @returns The created socket. This is returned by the default
1708
+ * implementation or by a custom synchronous `createConnection` implementation.
1709
+ * If a custom `createConnection` uses the `callback` for asynchronous
1710
+ * operation, this return value might not be the primary way to obtain the socket.
1698
1711
  */
1699
1712
  createConnection(
1700
1713
  options: ClientRequestArgs,
@@ -2123,6 +2136,27 @@ declare module "http" {
2123
2136
  * @param [max=1000]
2124
2137
  */
2125
2138
  function setMaxIdleHTTPParsers(max: number): void;
2139
+ /**
2140
+ * Dynamically resets the global configurations to enable built-in proxy support for
2141
+ * `fetch()` and `http.request()`/`https.request()` at runtime, as an alternative
2142
+ * to using the `--use-env-proxy` flag or `NODE_USE_ENV_PROXY` environment variable.
2143
+ * It can also be used to override settings configured from the environment variables.
2144
+ *
2145
+ * As this function resets the global configurations, any previously configured
2146
+ * `http.globalAgent`, `https.globalAgent` or undici global dispatcher would be
2147
+ * overridden after this function is invoked. It's recommended to invoke it before any
2148
+ * requests are made and avoid invoking it in the middle of any requests.
2149
+ *
2150
+ * See [Built-in Proxy Support](https://nodejs.org/docs/latest-v25.x/api/http.html#built-in-proxy-support) for details on proxy URL formats and `NO_PROXY`
2151
+ * syntax.
2152
+ * @since v25.4.0
2153
+ * @param proxyEnv An object containing proxy configuration. This accepts the
2154
+ * same options as the `proxyEnv` option accepted by {@link Agent}. **Default:**
2155
+ * `process.env`.
2156
+ * @returns A function that restores the original agent and dispatcher
2157
+ * settings to the state before this `http.setGlobalProxyFromEnv()` is invoked.
2158
+ */
2159
+ function setGlobalProxyFromEnv(proxyEnv?: ProxyEnv): () => void;
2126
2160
  /**
2127
2161
  * Global instance of `Agent` which is used as the default for all HTTP client
2128
2162
  * requests. Diverges from a default `Agent` configuration by having `keepAlive`
@@ -2149,6 +2183,6 @@ declare module "http" {
2149
2183
  */
2150
2184
  const MessageEvent: typeof import("undici-types").MessageEvent;
2151
2185
  }
2152
- declare module "node:http" {
2153
- export * from "http";
2186
+ declare module "http" {
2187
+ export * from "node:http";
2154
2188
  }