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
interfaceFn{(a: number): number;(a: string,b: number): number;}typeHKF=<Fextends(args: number)=>any>(f: F)=>Parameters<F>;declareconstfn: Fn;declareconsthkf: HKF;// The `result` will be infer as [string,number], we expect [number]constresult=hkf(fn);
In this example, our intend is the hkf function will choose the first signature of Fn,
because only the first signature match the type constraint that F extends (args: number) => any.
I test it in many times and found that,
Typescript always choose the last one signature of overload function in this case.
The text was updated successfully, but these errors were encountered:
When inferring from a type with multiple call signatures (such as the type of an overloaded function), inferences are made from the last signature (which, presumably, is the most permissive catch-all case). It is not possible to perform overload resolution based on a list of argument types (this would require us to support typeof for arbitrary expressions, as suggested in #6606, or something similar).
consider bellow example:
In this example, our intend is the
hkf
function will choose the first signature ofFn
,because only the first signature match the type constraint that
F extends (args: number) => any
.I test it in many times and found that,
Typescript always choose the last one signature of overload function in this case.
The text was updated successfully, but these errors were encountered: