Here's the issue: I need to pass T
, which could be a string
, number
, boolean
, object
, array
, or a function
. The problem is I can't figure out how to handle ab("hello")
in this scenario and return T as a value.
function a<T>(ab: T | ((v: T) => T)) {
if (typeof ab === "function") {
return ab("hello");
} else return ab;
}
This is the error that's been popping up: link to error https://i.sstatic.net/siE4L.png