Skip to content

Undesirable type argument inference from return position #20681

Closed
@DanielRosenwasser

Description

@DanielRosenwasser
let x: number[] = Array.from(
    [true, true, false]
)

Today, this code type checks because Array.from<T, U> takes an optional mapfn of type (el: T, index: number) => U.

When U is not inferred from the mapfn, it is instead inferred from the contextual type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions