How to set argument type for each function type in typescript?
each function is parameter.
[Example]
type F1 = (arg: number) => void;
type F2 = (arg: string) => void;
const caller = (f: F1 | F2) => (n: number | string): void => f(n);
<error>
parameter n: string | number
Argument of type 'string | number' is not assignable to parameter of type 'never'.
Type 'string' is not assignable to type 'never'.
typescript code is removed when comiled.
so, I think any logical code is not working...
how to do this?
[try]
(f as F1)(n as number);
(f as F2)(n as string);
But, it is not cool..
Thank you.