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
Commenting out the first construct signature for SetConstructor (in lib.es2015.collection.d.ts) produces the correct return type for collect. Likewise, uncommenting the similar constructor definition in MySet above results in collect producing the incorrect return type as well.
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.
TypeScript Version: 3.8.0-dev.20191210 (nightly)
Search Terms: inference generic overload construct signature
Code
Expected behavior:
The return type of the 1st call to
collect
should beSet<number>
, similar to how the return type of the 2nd call tocollect
isMySet<number>
Actual behavior:
The return type of the 1st call to
collect
isSet<unknown>
. This seems to be due to the combination of the following definitions:Commenting out the first construct signature for
SetConstructor
(in lib.es2015.collection.d.ts) produces the correct return type forcollect
. Likewise, uncommenting the similarconstructor
definition inMySet
above results incollect
producing the incorrect return type as well.Playground Link: 🔗
Related Issues: #25917, #35636 (possibly related?)
The text was updated successfully, but these errors were encountered: