Bug Description
The type for RedirectHandler constructor says the dispatch parameter takes a Dispatcher class, but the JS code uses dispatch as a function (that satisfies Dispatcher.dispatch).
Reproducible By
The example is compiled from the documentation:
|
const redirectHandler = new RedirectHandler( |
|
dispatch, |
|
maxRedirections, |
|
opts, |
|
handler |
|
) |
and the implementation of
compose:
|
let dispatch = this.dispatch.bind(this) |
const client = new Client('', {})
const handler: DispatchHandler = {}
// ERROR: Argument of type (options: DispatchOptions, handler: DispatchHandler) => boolean is not assignable to parameter of type Dispatcher.
const redirectHandler = new RedirectHandler(client.dispatch.bind(client), 10, {
path: '/', method: 'GET'
}, handler, false)
Expected Behavior
The parameter type is the same as Dispatcher.dispatch, and the example compiles successfully.
Environment
macOS 15.4.1, NodeJS 23.11.0
Additional context
The implementation of RedirectHandler constructor was updated in #1338, but the types weren't.
Bug Description
The type for
RedirectHandlerconstructor says thedispatchparameter takes aDispatcherclass, but the JS code usesdispatchas a function (that satisfiesDispatcher.dispatch).Reproducible By
The example is compiled from the documentation:
undici/docs/docs/api/Dispatcher.md
Lines 871 to 876 in 242ec9b
and the implementation of
compose:undici/lib/dispatcher/dispatcher.js
Line 23 in 67f3c96
Expected Behavior
The parameter type is the same as
Dispatcher.dispatch, and the example compiles successfully.Environment
macOS 15.4.1, NodeJS 23.11.0
Additional context
The implementation of
RedirectHandlerconstructor was updated in #1338, but the types weren't.