Skip to content

Commit f184975

Browse files
Fixed RedirectHandler type (#4278)
* Fixed RedirectHandler type * Fix test
1 parent d28d5ba commit f184975

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

test/types/index.test-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ expectAssignable<Dispatcher.DispatcherComposeInterceptor>(Undici.interceptors.re
1616
expectAssignable<Dispatcher.DispatcherComposeInterceptor>(Undici.interceptors.retry())
1717
expectAssignable<Dispatcher.DispatcherComposeInterceptor>(Undici.interceptors.cache())
1818

19-
const client = new Undici.Client('', {})
19+
const dispatcher = new Dispatcher()
2020
const handler: Dispatcher.DispatchHandler = {}
2121

22-
const redirectHandler = new Undici.RedirectHandler(client, 10, {
22+
const redirectHandler = new Undici.RedirectHandler(dispatcher.dispatch, 10, {
2323
path: '/', method: 'GET'
2424
}, handler, false) as RedirectHandler
2525
expectAssignable<RedirectHandler>(redirectHandler)

types/dispatcher.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ declare class Dispatcher extends EventEmitter {
9797

9898
declare namespace Dispatcher {
9999
export interface ComposedDispatcher extends Dispatcher {}
100-
export type DispatcherComposeInterceptor = (dispatch: Dispatcher['dispatch']) => Dispatcher['dispatch']
100+
export type Dispatch = Dispatcher['dispatch']
101+
export type DispatcherComposeInterceptor = (dispatch: Dispatch) => Dispatch
101102
export interface DispatchOptions {
102103
origin?: string | URL;
103104
path: string;
@@ -276,6 +277,6 @@ declare namespace Dispatcher {
276277
}
277278

278279
export interface DispatchInterceptor {
279-
(dispatch: Dispatcher['dispatch']): Dispatcher['dispatch']
280+
(dispatch: Dispatch): Dispatch
280281
}
281282
}

types/handlers.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Dispatcher from './dispatcher'
22

33
export declare class RedirectHandler implements Dispatcher.DispatchHandler {
44
constructor (
5-
dispatch: Dispatcher,
5+
dispatch: Dispatcher.Dispatch,
66
maxRedirections: number,
77
opts: Dispatcher.DispatchOptions,
88
handler: Dispatcher.DispatchHandler,

0 commit comments

Comments
 (0)