It seems that the Function
interface does not include a callable signature in its declaration. However, if you have an object of type Function
, you can call it as long as it is treated as (...args: any) => any
. There is an open issue, which may be a bit outdated, at microsoft/TypeScript#20007, requesting a change to this behavior. A comment on the issue states:
The original purpose of the Function
interface was for it not to be callable. In other words, Function
in relation to function types should be similar to unknown
in relation to other types, not callable. We have relaxed this restriction by allowing Function
to behave as callable in the compiler through special handling. It has been suggested to make this a --noImplicitAny
error because calling Function
s can be unsafe.
If you are passionate about this issue, consider visiting the linked issue and expressing your support 👍 while explaining your use case. Realistically, however, the chances of it being changed are slim, so it might be best to acknowledge the discrepancy and move forward.