function function<T>(argument: T | (() => T)) {
// @ts-expect-error
return typeof argument === "function" ? argument() : argument;
}
Despite using the typeof
type guard, I'm unable to call argument
, but this issue only arises when working with a generic function. In other cases, it functions correctly:
function function(argument: string | (() => string)) {
return typeof argument === "function" ? argument() : argument;
}
I'm puzzled by this behavior and unclear on how to resolve it. Any assistance would be greatly appreciated!