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
I have same issue in another example (TypeScript version: 3.2.2)
functionfoo(a: number,b: string): void;functionfoo(a: string): void;functionfoo(a: string|number,b?: string){}foo.call(null,1,"2");// Expected 2 arguments, but got 3.foo.bind(null)(1,"2");// Expected 1 arguments, but got 2.foo.apply(null,[1,"2"]);// Type 'number' is not assignable to type 'string'.foo.call(null,"2");// no errorsfoo(1,"2");// no errorsfoo("2");// no errors
So I can't use call/bind/apply with overloaded functions.
Bludator That is a separate issue linked to the design of conditional type inference. When inferring from an overloaded function the last overload is always picked, so Parameters just picks up the last case which happens to be never.
Activity
wKich commentedon Jan 9, 2019
I have same issue in another example (TypeScript version: 3.2.2)
So I can't use
call/bind/applywith overloaded functions.Update: Sorry, I didn't see #27028 (comment)
Bludator commentedon Mar 3, 2019
I have yet another example:link to playground.
jack-williams commentedon Mar 3, 2019
Bludator That is a separate issue linked to the design of conditional type inference. When inferring from an overloaded function the last overload is always picked, so
Parametersjust picks up the last case which happens to benever.See #21496
RyanCavanaugh commentedon Jul 23, 2019
Inference only works with the last overload