I want to define a function that gets as parameters another function f and its arguments args, and I want Typescript to make sure that the passed arguments are correct for the passed function.
Pseudo code
function A (n: number, s: string, b: boolean) {
...
}
function B (f: Function, ...args: typeof arguments of f) {
...
f(args)
}
B(A, 1, 'str', true) // typescript is happy
B(A, 1, 'str') // typescript is sad
B(A, 1, undefined, true) // typescript is sad
// any other example of wrong arguments of A passed to b would raise Typescript error...
So the important part here is this:
...args: typeof arguments of f
Which is obviously not valid Typescript.
How can I write typescript code that does that?