I have the following function in index.js file:
function myFn(val) {
if (val) {
return val;
}
return console.log(val);
}
I have the following type declaration in index.d.ts file:
declare function myFn<T>(val?: T): (T | void);
But the problem is that if i pass no arguemnt then there is no case where the function can return any value other than void type.
I would like to do something like this:
declare function myFn<T>: (val?: T) => (val ? T : void);
How can i implement this best? any ideas?