In Typescript I want to create a function that will take a function and return a function with the same input-output. the function itself needs to be generic. so that it can
Here you go :
function f<A extends Function>(a:A):A {
var newFunc = (...x:any[]) => {
console.log('('+x.join(',')+') => ', a.apply(undefined, x));
return null;
}
return <any>newFunc;
}
function a(j:string, k:number): boolean {
return j === String(k);
}
var b = f(a);
b("1", 1);
b("a", 2);
b('123','123'); // ERROR