From 397f163a0c53bde62dee40b4b35a233cd4d01e48 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 28 Jul 2025 22:03:45 +0200 Subject: [PATCH 1/2] fix: remove deprecated maxRedirections option from types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The maxRedirections option was removed in v7 but still remained in TypeScript type definitions. This removes it from: - Agent.Options and Agent.DispatchOptions - Dispatcher ConnectOptions, RequestOptions, and UpgradeOptions - Client.Options and H2CClient.Options - MockInterceptor.MockResponseCallbackOptions Also updates corresponding type tests to remove usage of the deprecated option. The redirect interceptor still supports maxRedirections as that functionality remains available. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Signed-off-by: Matteo Collina --- test/types/agent.test-d.ts | 4 ++-- test/types/client.test-d.ts | 2 +- test/types/dispatcher.test-d.ts | 18 +++++++++--------- test/types/env-http-proxy-agent.test-d.ts | 2 +- test/types/mock-interceptor.test-d.ts | 1 - test/types/proxy-agent.test-d.ts | 1 - types/agent.d.ts | 4 ---- types/client.d.ts | 2 -- types/dispatcher.d.ts | 6 ------ types/h2c-client.d.ts | 2 -- types/mock-interceptor.d.ts | 1 - 11 files changed, 13 insertions(+), 30 deletions(-) diff --git a/test/types/agent.test-d.ts b/test/types/agent.test-d.ts index 72e27293418..29943709720 100644 --- a/test/types/agent.test-d.ts +++ b/test/types/agent.test-d.ts @@ -5,7 +5,7 @@ import { URL } from 'url' expectAssignable(new Agent()) expectAssignable(new Agent({})) -expectAssignable(new Agent({ maxRedirections: 1 })) +expectAssignable(new Agent({})) expectAssignable(new Agent({ factory: () => new Dispatcher() })) { @@ -99,7 +99,7 @@ expectAssignable(new Agent({ factory: () => new Dispatcher() })) // dispatch expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET' }, {})) - expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET', maxRedirections: 1 }, {})) + expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET' }, {})) // close expectAssignable>(agent.close()) diff --git a/test/types/client.test-d.ts b/test/types/client.test-d.ts index 61168a1a5bb..00d5b1dea21 100644 --- a/test/types/client.test-d.ts +++ b/test/types/client.test-d.ts @@ -77,7 +77,7 @@ expectAssignable( ) expectAssignable( new Client('', { - maxRedirections: 1 + maxCachedSessions: 1 }) ) expectAssignable( diff --git a/test/types/dispatcher.test-d.ts b/test/types/dispatcher.test-d.ts index 4f26dc0adf1..3e43eddd1cf 100644 --- a/test/types/dispatcher.test-d.ts +++ b/test/types/dispatcher.test-d.ts @@ -46,8 +46,8 @@ expectAssignable(new Dispatcher()) expectAssignable(dispatcher.dispatch({ path: '', method: 'CUSTOM' }, {})) // connect - expectAssignable>(dispatcher.connect({ origin: '', path: '', maxRedirections: 0 })) - expectAssignable>(dispatcher.connect({ origin: new URL('http://localhost'), path: '', maxRedirections: 0 })) + expectAssignable>(dispatcher.connect({ origin: '', path: '' })) + expectAssignable>(dispatcher.connect({ origin: new URL('http://localhost'), path: '' })) expectAssignable(dispatcher.connect({ origin: '', path: '' }, (err, data) => { expectAssignable(err) expectAssignable(data) @@ -73,10 +73,10 @@ expectAssignable(new Dispatcher()) expectAssignable>(dispatcher.connect({ origin: '', path: '', headers: iteratorHeaders })) // request - expectAssignable>(dispatcher.request({ origin: '', path: '', method: 'GET', maxRedirections: 0 })) - expectAssignable>(dispatcher.request({ origin: '', path: '', method: 'GET', maxRedirections: 0, query: {} })) - expectAssignable>(dispatcher.request({ origin: '', path: '', method: 'GET', maxRedirections: 0, query: { pageNum: 1, id: 'abc' } })) - expectAssignable>(dispatcher.request({ origin: '', path: '', method: 'GET', maxRedirections: 0, throwOnError: true })) + expectAssignable>(dispatcher.request({ origin: '', path: '', method: 'GET' })) + expectAssignable>(dispatcher.request({ origin: '', path: '', method: 'GET', query: {} })) + expectAssignable>(dispatcher.request({ origin: '', path: '', method: 'GET', query: { pageNum: 1, id: 'abc' } })) + expectAssignable>(dispatcher.request({ origin: '', path: '', method: 'GET', throwOnError: true })) expectAssignable>(dispatcher.request({ origin: new URL('http://localhost'), path: '', method: 'GET' })) expectAssignable(dispatcher.request({ origin: '', path: '', method: 'GET', reset: true }, (err, data) => { expectAssignable(err) @@ -91,7 +91,7 @@ expectAssignable(new Dispatcher()) expectAssignable>>(dispatcher.request({ origin: '', path: '', method: 'GET', opaque: { example: '' } })) // pipeline - expectAssignable(dispatcher.pipeline({ origin: '', path: '', method: 'GET', maxRedirections: 0 }, data => { + expectAssignable(dispatcher.pipeline({ origin: '', path: '', method: 'GET' }, data => { expectAssignable(data) return new Readable() })) @@ -114,7 +114,7 @@ expectAssignable(new Dispatcher()) })) // stream - expectAssignable>(dispatcher.stream({ origin: '', path: '', method: 'GET', maxRedirections: 0 }, data => { + expectAssignable>(dispatcher.stream({ origin: '', path: '', method: 'GET' }, data => { expectAssignable(data) return new Writable() })) @@ -170,7 +170,7 @@ expectAssignable(new Dispatcher()) })) // upgrade - expectAssignable>(dispatcher.upgrade({ path: '', maxRedirections: 0 })) + expectAssignable>(dispatcher.upgrade({ path: '' })) expectAssignable(dispatcher.upgrade({ path: '' }, (err, data) => { expectAssignable(err) expectAssignable(data) diff --git a/test/types/env-http-proxy-agent.test-d.ts b/test/types/env-http-proxy-agent.test-d.ts index e6370e4418a..17bd82db546 100644 --- a/test/types/env-http-proxy-agent.test-d.ts +++ b/test/types/env-http-proxy-agent.test-d.ts @@ -94,7 +94,7 @@ expectAssignable(new EnvHttpProxyAgent({ httpProxy: 'http://l // dispatch expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET' }, {})) - expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET', maxRedirections: 1 }, {})) + expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET' }, {})) // close expectAssignable>(agent.close()) diff --git a/test/types/mock-interceptor.test-d.ts b/test/types/mock-interceptor.test-d.ts index 5c351d28112..94d65583a99 100644 --- a/test/types/mock-interceptor.test-d.ts +++ b/test/types/mock-interceptor.test-d.ts @@ -52,7 +52,6 @@ expectAssignable(mockResponseCall expectAssignable(options.headers) expectAssignable(options.origin) expectAssignable(options.body) - expectAssignable(options.maxRedirections) return { statusCode: 200, data: { foo: 'bar' } } }) diff --git a/test/types/proxy-agent.test-d.ts b/test/types/proxy-agent.test-d.ts index 7cc092ba4a8..df545c8d38b 100644 --- a/test/types/proxy-agent.test-d.ts +++ b/test/types/proxy-agent.test-d.ts @@ -10,7 +10,6 @@ expectAssignable( uri: '', auth: '', token: '', - maxRedirections: 1, factory: (_origin: URL, opts: Object) => new Agent(opts), requestTls: { ca: [''], diff --git a/types/agent.d.ts b/types/agent.d.ts index 2132560744a..8c881481a46 100644 --- a/types/agent.d.ts +++ b/types/agent.d.ts @@ -22,14 +22,10 @@ declare namespace Agent { export interface Options extends Pool.Options { /** Default: `(origin, opts) => new Pool(origin, opts)`. */ factory?(origin: string | URL, opts: Object): Dispatcher; - /** Integer. Default: `0` */ - maxRedirections?: number; interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options['interceptors'] } export interface DispatchOptions extends Dispatcher.DispatchOptions { - /** Integer. */ - maxRedirections?: number; } } diff --git a/types/client.d.ts b/types/client.d.ts index 088a673eb52..bd1a32c380a 100644 --- a/types/client.d.ts +++ b/types/client.d.ts @@ -71,8 +71,6 @@ export declare namespace Client { /** TODO */ maxCachedSessions?: number; /** TODO */ - maxRedirections?: number; - /** TODO */ connect?: Partial | buildConnector.connector; /** TODO */ maxRequestsPerClient?: number; diff --git a/types/dispatcher.d.ts b/types/dispatcher.d.ts index 5da4c720c20..fffe870c272 100644 --- a/types/dispatcher.d.ts +++ b/types/dispatcher.d.ts @@ -135,8 +135,6 @@ declare namespace Dispatcher { signal?: AbortSignal | EventEmitter | null; /** This argument parameter is passed through to `ConnectData` */ opaque?: TOpaque; - /** Default: 0 */ - maxRedirections?: number; /** Default: false */ redirectionLimitReached?: boolean; /** Default: `null` */ @@ -147,8 +145,6 @@ declare namespace Dispatcher { opaque?: TOpaque; /** Default: `null` */ signal?: AbortSignal | EventEmitter | null; - /** Default: 0 */ - maxRedirections?: number; /** Default: false */ redirectionLimitReached?: boolean; /** Default: `null` */ @@ -172,8 +168,6 @@ declare namespace Dispatcher { protocol?: string; /** Default: `null` */ signal?: AbortSignal | EventEmitter | null; - /** Default: 0 */ - maxRedirections?: number; /** Default: false */ redirectionLimitReached?: boolean; /** Default: `null` */ diff --git a/types/h2c-client.d.ts b/types/h2c-client.d.ts index 2e878694758..e7a6808df36 100644 --- a/types/h2c-client.d.ts +++ b/types/h2c-client.d.ts @@ -51,8 +51,6 @@ export declare namespace H2CClient { /** TODO */ maxCachedSessions?: number; /** TODO */ - maxRedirections?: number; - /** TODO */ connect?: Omit, 'allowH2'> | buildConnector.connector; /** TODO */ maxRequestsPerClient?: number; diff --git a/types/mock-interceptor.d.ts b/types/mock-interceptor.d.ts index 83c0b3831ef..a48d715a4cd 100644 --- a/types/mock-interceptor.d.ts +++ b/types/mock-interceptor.d.ts @@ -69,7 +69,6 @@ declare namespace MockInterceptor { headers?: Headers | Record; origin?: string; body?: BodyInit | Dispatcher.DispatchOptions['body'] | null; - maxRedirections?: number; } export type MockResponseDataHandler = ( From 4c1a2792de36c5c927b5e15a62cc56b1f4a71f96 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 29 Jul 2025 10:55:39 +0200 Subject: [PATCH 2/2] fixup Signed-off-by: Matteo Collina --- test/types/agent.test-d.ts | 2 -- test/types/env-http-proxy-agent.test-d.ts | 1 - 2 files changed, 3 deletions(-) diff --git a/test/types/agent.test-d.ts b/test/types/agent.test-d.ts index 29943709720..6caab595392 100644 --- a/test/types/agent.test-d.ts +++ b/test/types/agent.test-d.ts @@ -5,7 +5,6 @@ import { URL } from 'url' expectAssignable(new Agent()) expectAssignable(new Agent({})) -expectAssignable(new Agent({})) expectAssignable(new Agent({ factory: () => new Dispatcher() })) { @@ -99,7 +98,6 @@ expectAssignable(new Agent({ factory: () => new Dispatcher() })) // dispatch expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET' }, {})) - expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET' }, {})) // close expectAssignable>(agent.close()) diff --git a/test/types/env-http-proxy-agent.test-d.ts b/test/types/env-http-proxy-agent.test-d.ts index 17bd82db546..02711027a42 100644 --- a/test/types/env-http-proxy-agent.test-d.ts +++ b/test/types/env-http-proxy-agent.test-d.ts @@ -94,7 +94,6 @@ expectAssignable(new EnvHttpProxyAgent({ httpProxy: 'http://l // dispatch expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET' }, {})) - expectAssignable(agent.dispatch({ origin: '', path: '', method: 'GET' }, {})) // close expectAssignable>(agent.close())