-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
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
Milestone
Description
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
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