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 inference because of generic function argument #16107

Copy link
Copy link
@gcnew

Description

@gcnew
Issue body actions

TypeScript Version: nightly (2.4.0-dev.20170502)

TypeScript improperly infers a union type when a generic function is used as an argument. Such an inference is unexpected unless the union constituent is present, or the type arguments are manually provided by the programmer.

Code

declare function sameType<T>(x: T, y: T): T;
declare function test<R>(f: (x: string, y: number) => R): void;

test(sameType); // bad inference: R = string | number
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeBugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

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.