You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
declarefunctionsameType<T>(x: T,y: T): T;declarefunctiontest<R>(f: (x: string,y: number)=>R): void;test(sameType);// bad inference: R = string | number
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