Is it wishful thinking to try and achieve the following?
I am aiming to create a function (let's call it function A) that will return the same type as a new function passed into its parameter.
For example:
export function test<T> ( arg:Function ):T {
return arg;
}
function a():string {
return 'a';
}
function b():number {
return 0;
}
let aVal:string = test(a);
let bVal:number = test(b);
This approach can help in strongly typing responses and catching compile time errors.
Does anyone have any insights or thoughts on this concept?
** Please note: The code is put together quickly for demonstration purposes **
Cheers!