I am working with a union type of functions:
function Function1(arg0: string, arg1: any[], name: "hello" | "bye") {
return name;
}
function Function2(arg0: string, arg1: any[], name: "foo" | "bar") {
return name;
}
type Functions = typeof Function1 | typeof Function2;
Currently, I am trying to define a new type that can take a tuple where the first element is the actual function and the second element is the corresponding "name" argument.
const baz = [Function1, "foo"];
I attempted the following approach:
type FooBar<T = Functions> = [T, Parameters<T>[2]];
Initially, it throws an error at Parameters<T>[2]
stating "Type 'T' does not satisfy the constraint '(...args: any) => any'
"
While it almost works, it retrieves all arguments from both functions instead.