Skip to content

Promise catch error parameter should not be of type any. #6283

@tinganho

Description

@tinganho

Is there any chance, you could change the any type on error parameter on the catch method of a Promise, to a type argument instead? The type argument is provided in the Promise<R, E> type annotation, instead of just Promise<R> .

    /**
     * Sugar for promise.then(undefined, onRejected)
     *
     * @param onRejected called when/if "promise" rejects
     */
    catch<U>(onRejected?: (error: any) => U | Thenable<U>): Promise<U>;

I need to type annotate many catch method calls right now with:

.catch(error:  HTTPResponse<ErrorResponse> | Error)

Metadata

Metadata

Assignees

Labels

Working as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions