Hi there,
I'm trying to implement a type-safe version of a vararg function whose arguments are defined in a specific order.
So far I came to the following type declaration:
type PairArgs<L, R> = [L, R, ...PairArgs<L, R>[]];
function foo(arg1: string, ...rest: PairArgs<string, number>);
// Usage:
foo("arg1", "one", 1, "two", 2, "three", 3);
But this only solves the problem for paired arguments (let's call it TupleOfTwo).
Now, I want to introduce a generic version of it (TupleOfN), so I'm trying this:
type TupleArgs<Types extends unknown[]> = [...Types, ...TupleArgs<Types>[]];
but it doesn't work (Type alias TupleArgs circularly references itself.
Is there any way to do a generic N-ary version of such a tuple?
