At this point, I have a function that takes in two parameters: param 'a' as a string and 'b' as a function that returns a string. My intention is to call it using a rest parameter and specify the types accordingly.
However, on line 10 (the last line), the TypeScript compiler is generating an error message saying "Argument of type '"a"' is not assignable to parameter of type 'TFoo'.ts(2345)".
type TFoo = () => string | string;
function foo(...args: TFoo[]) {
let [a, b] = args;
if (typeof b === 'function') {
b = b();
}
}
foo('a', () => 'baz');
My expectation is for TypeScript to allow strings or functions as arguments for these function parameters.
Is there a way to resolve this issue?