Skip to content

Generic type inferred as supertype if that's the callback parameter type #12915

Description

TypeScript Version: nightly (2.2.0-dev.20161214)

(Ref: #12862 (comment))

Code

function f<T>(x: T[], y: (t: T) => void): T[] { return x; }
function g(value: {}): void {}
const x: number[] = f([1, 2], g);

Expected behavior:

Infers f<number>.

Actual behavior:

Infers f<{}>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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