Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unexpected union type between generic and non-generic function #12970

Copy link
Copy link
@gcnew

Description

@gcnew
Issue body actions

TypeScript Version: nightly (2.2.0)

Code

function id<T>(x: T): T {
    return x;
}

function stringId(x: string): string {
    return x;
}

function numberId(x: number): number {
    return x;
}

// OK: ((x: string) => string) | ((x: number) => number)
const f = true ? numberId : stringId;

// Actual: <T>(x: T) => T
// Expected: (x: string) => string
const g = true ? id : stringId;

Expected behavior:
Union between a function and a generic function should yield the most specific type, not the most general one.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.

    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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.