Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions test/types/agent.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { URL } from 'url'

expectAssignable<Agent>(new Agent())
expectAssignable<Agent>(new Agent({}))
expectAssignable<Agent>(new Agent({ maxRedirections: 1 }))
expectAssignable<Agent>(new Agent({ factory: () => new Dispatcher() }))

{
Expand Down Expand Up @@ -99,7 +98,6 @@ expectAssignable<Agent>(new Agent({ factory: () => new Dispatcher() }))

// dispatch
expectAssignable<boolean>(agent.dispatch({ origin: '', path: '', method: 'GET' }, {}))
expectAssignable<boolean>(agent.dispatch({ origin: '', path: '', method: 'GET', maxRedirections: 1 }, {}))

// close
expectAssignable<Promise<void>>(agent.close())
Expand Down
2 changes: 1 addition & 1 deletion test/types/client.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ expectAssignable<Client>(
)
expectAssignable<Client>(
new Client('', {
maxRedirections: 1
maxCachedSessions: 1
})
)
expectAssignable<Client>(
Expand Down
18 changes: 9 additions & 9 deletions test/types/dispatcher.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ expectAssignable<Dispatcher>(new Dispatcher())
expectAssignable<boolean>(dispatcher.dispatch({ path: '', method: 'CUSTOM' }, {}))

// connect
expectAssignable<Promise<Dispatcher.ConnectData>>(dispatcher.connect({ origin: '', path: '', maxRedirections: 0 }))
expectAssignable<Promise<Dispatcher.ConnectData>>(dispatcher.connect({ origin: new URL('http://localhost'), path: '', maxRedirections: 0 }))
expectAssignable<Promise<Dispatcher.ConnectData>>(dispatcher.connect({ origin: '', path: '' }))
expectAssignable<Promise<Dispatcher.ConnectData>>(dispatcher.connect({ origin: new URL('http://localhost'), path: '' }))
expectAssignable<void>(dispatcher.connect({ origin: '', path: '' }, (err, data) => {
expectAssignable<Error | null>(err)
expectAssignable<Dispatcher.ConnectData>(data)
Expand All @@ -73,10 +73,10 @@ expectAssignable<Dispatcher>(new Dispatcher())
expectAssignable<Promise<Dispatcher.ConnectData>>(dispatcher.connect({ origin: '', path: '', headers: iteratorHeaders }))

// request
expectAssignable<Promise<Dispatcher.ResponseData>>(dispatcher.request({ origin: '', path: '', method: 'GET', maxRedirections: 0 }))
expectAssignable<Promise<Dispatcher.ResponseData>>(dispatcher.request({ origin: '', path: '', method: 'GET', maxRedirections: 0, query: {} }))
expectAssignable<Promise<Dispatcher.ResponseData>>(dispatcher.request({ origin: '', path: '', method: 'GET', maxRedirections: 0, query: { pageNum: 1, id: 'abc' } }))
expectAssignable<Promise<Dispatcher.ResponseData>>(dispatcher.request({ origin: '', path: '', method: 'GET', maxRedirections: 0, throwOnError: true }))
expectAssignable<Promise<Dispatcher.ResponseData>>(dispatcher.request({ origin: '', path: '', method: 'GET' }))
expectAssignable<Promise<Dispatcher.ResponseData>>(dispatcher.request({ origin: '', path: '', method: 'GET', query: {} }))
expectAssignable<Promise<Dispatcher.ResponseData>>(dispatcher.request({ origin: '', path: '', method: 'GET', query: { pageNum: 1, id: 'abc' } }))
expectAssignable<Promise<Dispatcher.ResponseData>>(dispatcher.request({ origin: '', path: '', method: 'GET', throwOnError: true }))
expectAssignable<Promise<Dispatcher.ResponseData>>(dispatcher.request({ origin: new URL('http://localhost'), path: '', method: 'GET' }))
expectAssignable<void>(dispatcher.request({ origin: '', path: '', method: 'GET', reset: true }, (err, data) => {
expectAssignable<Error | null>(err)
Expand All @@ -91,7 +91,7 @@ expectAssignable<Dispatcher>(new Dispatcher())
expectAssignable<Promise<Dispatcher.ResponseData<{ example: string }>>>(dispatcher.request({ origin: '', path: '', method: 'GET', opaque: { example: '' } }))

// pipeline
expectAssignable<Duplex>(dispatcher.pipeline({ origin: '', path: '', method: 'GET', maxRedirections: 0 }, data => {
expectAssignable<Duplex>(dispatcher.pipeline({ origin: '', path: '', method: 'GET' }, data => {
expectAssignable<Dispatcher.PipelineHandlerData>(data)
return new Readable()
}))
Expand All @@ -114,7 +114,7 @@ expectAssignable<Dispatcher>(new Dispatcher())
}))

// stream
expectAssignable<Promise<Dispatcher.StreamData>>(dispatcher.stream({ origin: '', path: '', method: 'GET', maxRedirections: 0 }, data => {
expectAssignable<Promise<Dispatcher.StreamData>>(dispatcher.stream({ origin: '', path: '', method: 'GET' }, data => {
expectAssignable<Dispatcher.StreamFactoryData>(data)
return new Writable()
}))
Expand Down Expand Up @@ -170,7 +170,7 @@ expectAssignable<Dispatcher>(new Dispatcher())
}))

// upgrade
expectAssignable<Promise<Dispatcher.UpgradeData>>(dispatcher.upgrade({ path: '', maxRedirections: 0 }))
expectAssignable<Promise<Dispatcher.UpgradeData>>(dispatcher.upgrade({ path: '' }))
expectAssignable<void>(dispatcher.upgrade({ path: '' }, (err, data) => {
expectAssignable<Error | null>(err)
expectAssignable<Dispatcher.UpgradeData>(data)
Expand Down
1 change: 0 additions & 1 deletion test/types/env-http-proxy-agent.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ expectAssignable<EnvHttpProxyAgent>(new EnvHttpProxyAgent({ httpProxy: 'http://l

// dispatch
expectAssignable<boolean>(agent.dispatch({ origin: '', path: '', method: 'GET' }, {}))
expectAssignable<boolean>(agent.dispatch({ origin: '', path: '', method: 'GET', maxRedirections: 1 }, {}))

// close
expectAssignable<Promise<void>>(agent.close())
Expand Down
1 change: 0 additions & 1 deletion test/types/mock-interceptor.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ expectAssignable<BodyInit | Dispatcher.DispatchOptions['body']>(mockResponseCall
expectAssignable<MockInterceptor.MockResponseCallbackOptions['headers']>(options.headers)
expectAssignable<MockInterceptor.MockResponseCallbackOptions['origin']>(options.origin)
expectAssignable<MockInterceptor.MockResponseCallbackOptions['body']>(options.body)
expectAssignable<MockInterceptor.MockResponseCallbackOptions['maxRedirections']>(options.maxRedirections)
return { statusCode: 200, data: { foo: 'bar' } }
})

Expand Down
1 change: 0 additions & 1 deletion test/types/proxy-agent.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ expectAssignable<ProxyAgent>(
uri: '',
auth: '',
token: '',
maxRedirections: 1,
factory: (_origin: URL, opts: Object) => new Agent(opts),
requestTls: {
ca: [''],
Expand Down
4 changes: 0 additions & 4 deletions types/agent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 0 additions & 2 deletions types/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export declare namespace Client {
/** TODO */
maxCachedSessions?: number;
/** TODO */
maxRedirections?: number;
/** TODO */
connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
/** TODO */
maxRequestsPerClient?: number;
Expand Down
6 changes: 0 additions & 6 deletions types/dispatcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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` */
Expand All @@ -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` */
Expand All @@ -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` */
Expand Down
2 changes: 0 additions & 2 deletions types/h2c-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ export declare namespace H2CClient {
/** TODO */
maxCachedSessions?: number;
/** TODO */
maxRedirections?: number;
/** TODO */
connect?: Omit<Partial<buildConnector.BuildOptions>, 'allowH2'> | buildConnector.connector;
/** TODO */
maxRequestsPerClient?: number;
Expand Down
1 change: 0 additions & 1 deletion types/mock-interceptor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ declare namespace MockInterceptor {
headers?: Headers | Record<string, string>;
origin?: string;
body?: BodyInit | Dispatcher.DispatchOptions['body'] | null;
maxRedirections?: number;
}

export type MockResponseDataHandler<TData extends object = object> = (
Expand Down
Loading