I'd like to be able to define a method that accepts an arrow function as a parameter. The function parameter should be able to define 0 or more named parameters of its own. How can I do this?
I've tried
public doSomething(fn: () => any) {}
and
public doSomething(fn: (...args) => any) {}
but they both throw a "supplied parameters do not match" error when I try to call it as follows:
doSomething((test: string) => {})
(Note that the type and number of parameters to this function may vary on each usage, so I can't set the type(s) on the original method.)
I can supply parameters using the ...args
syntax within the passed function, but I would like to be able to type and name specific parameters.
Is there a way to do this?