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 take any number of arguments and return any type.
function improveFunction <T,U>(func:'that takes T and returns U') : (T):U {
var newFunc = doDomethingToTheFunction(func);
return newFunc;
}
if I was returning the function itself this would work. But since I am using the arguments special parameter to be able to accept any number of argument I am in fact creating a new function that the typescript compiler can't understand.
Edit:
I made one more variant to go from
(U => T) to (U => Promise<T>)
function ddd<T>(func: (...x: any[]) => T) : (...x: any[]) => ng.IPromise<T> {
// return a function returning a promise of T;
}