Skip to content

Incorrect types on RedirectHandler #4229

Description

@koterpillar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions