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
{{ message }}
Repository navigation
Incorrect overload is used for pipe when first function has optional parameter #29913
How come this behaviour only applies when strictFunctionTypes is disabled?
This is the order of overloads used by Lodash's flow (aka pipe) function. I have raised a PR to fix the overload order, as you suggested: DefinitelyTyped/DefinitelyTyped#33450.
strictFunctionTypes off means that parameter types are compared bivariantly, so the {} | undefined being assignable from the implicit no-argument undefined is acceptable.
Activity
RyanCavanaugh commentedon Feb 27, 2019
The first overload that matches is always chosen. The
pipeoverloads should be in the other order.OliverJAsh commentedon Feb 27, 2019
How come this behaviour only applies when
strictFunctionTypesis disabled?This is the order of overloads used by Lodash's
flow(akapipe) function. I have raised a PR to fix the overload order, as you suggested: DefinitelyTyped/DefinitelyTyped#33450.RyanCavanaugh commentedon Feb 27, 2019
strictFunctionTypesoff means that parameter types are compared bivariantly, so the{} | undefinedbeing assignable from the implicit no-argumentundefinedis acceptable.OliverJAsh commentedon Sep 18, 2019
If we do this, it fixes the example above, but it causes other issues:
Workaround: use generic rest parameters: