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
Search Terms:
is:issue is:open return type generic unknown
Code
declarefunctionf<T>(x: T): T;declarefunctiong(x: number): number;typeF=typeoff;// type F = <T>(x: T) => T;typeG=typeofg;// type G = (x: number) => number;typeTypedReturn<Fnextends(...args: any[])=>any,Argsextendsany[]>=Fnextends<AextendsArgs>(...args: A)=> infer R ? R : never;typeTypedReturn1<Fnextends(arg: any)=>any,Arg>=Fnextends<AextendsArg>(arg: A)=> infer R ? R : never;typeFR=TypedReturn<F,[number]>;// expected: type FR = number;// actual: type FR = unknown;typeGR=TypedReturn<G,[number]>;// expected: type GR = number;// actual: type GR = number;typeFR1=TypedReturn1<F,number>;// expected: type FR1 = number;// actual: type FR1 = unknown;typeGR1=TypedReturn1<G,number>;// expected: type GR1 = number;// actual: type GR1 = number;// These types are proofs of a bugtypeF_Infer_OK=Fextends(...args: [number])=>number ? true : false;// type F_Infer_OK = true;typeF_Infer1_OK=Fextends(x: number)=>number ? true : false;// type F_Infer1_OK = true;typeF_Infer_FAIL_1=Fextends(...args: [number])=>string ? true : false;// type F_Infer_FAIL_1 = false;typeF_Infer1_FAIL_1=Fextends(x: number)=>string ? true : false;// type F_Infer1_FAIL_1 = false;typeF_Infer_FAIL_2=Fextends(...args: [string])=>number ? true : false;// type F_Infer_FAIL_2 = false;typeF_Infer1_FAIL_2=Fextends(x: string)=>number ? true : false;// type F_Infer1_FAIL_2 = false;
This is effectively a duplicate of #22617. As I mention there, the fix would be to have type inference in conditional types perform instantiation of a source type in the context of a target type when the source type is a generic function type.
TypeScript Version: from 3.5.1 to 4.0.0-beta
Search Terms:
is:issue is:open return type generic unknown
Code
Expected behavior:
See comments in Code section
Actual behavior:
See comments in Code section
Playground link
Related Issues:
No direct related issues found.
The text was updated successfully, but these errors were encountered: