Considering the provided type definition
export interface MyFun {
(arg: unknown): unknown;
}
It is straightforward to annotate an arrow function like this:
const arrowF: MyFun = arg => {
console.log(arg);
}
However, annotating a regular function with the same type raises a question:
function regularF(arg) {
console.log(arg);
}
The compiler will throw an error message:
Parameter 'arg' implicitly has an 'any' type.
An attempt to specify the type directly in the function declaration does not yield the expected result:
function<MyFun> regularF(arg) {
console.log(arg);
}
Unfortunately, this approach does not work as intended. For more information, refer to this related issue.