Skip to content

Underscore: chained reduce returns wrong type #7931

@palortoff

Description

@palortoff

A chained reduce on an array returns a _ChainSingle, event if TResult is an array. In this case the reduce result is fully chainable and therefore should be a _Chain.

Example:

_.chain([1, 2, 3])
            .reduce((acc, x) => [x], [])
            .map(() => 1)
            .value()

Results in TS error:

error TS2339: Property 'map' does not exist on type '_ChainSingle<any[]>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions