-
-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
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:
undici/docs/docs/api/Dispatcher.md
Lines 871 to 876 in 242ec9b
| const redirectHandler = new RedirectHandler( | |
| dispatch, | |
| maxRedirections, | |
| opts, | |
| handler | |
| ) |
and the implementation of
compose: undici/lib/dispatcher/dispatcher.js
Line 23 in 67f3c96
| 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working