Skip to content

Error when Reduce is used more than one-time #15

@oonsamyi

Description

@oonsamyi

When a function that uses Reduce type is called more than one-time, flow error occurs:

type MergeAll<T> = Reduce<<X, V>(V) => X => { ...$Exact<X>, ...$Exact<V> }, {}, T>

declare function mergeAll<A>(A): MergeAll<A>

const x = mergeAll([{ a: 1 }, { b: 1 }, { c: 1 }, { a: 2 }])
const xx = mergeAll([{ a: 1 }, { b: 1 }, { c: 1 }, { a: 2 }])

// try to comment this line, the error disappears
;(x: { a: 2, b: 1, c: 1 }) // rightly

// or try to comment this line, the error disappears too
;(xx: { a: 2, b: 1, c: 1 }) // error?!

Link to repl

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions