The error says Supplied parameter do not match any signature of call target.
When I replace Function with any as the second parameter's type, the error disappears. But any is the same as no type, isn't there a suitable type for functions as parameters?
1 Answer
Instead of Function (or any) you can use the following type for your callback parameter:
(ev: Event)=> any
This matches the type expected by addEventListener.
Here is the full function signature:
on(eventName: string, callback: (ev: Event)=> any, useCapture: boolean) : Dom.Element {
//...
2 Comments
jstice4all
Ok. So it means the type is function with ev parameter of type Event that returns any?
Fenton
Yes - although think of the return type as simply being very permissive. You can pass a function that returns void, or a string, or a number - whatever you like; allow any return type.