Is it possible in Typescript to implement an infinite Array (not a Tuple) with a type that depends on the previous element of the array?
Here's some pseudo-typescript code to give an example:
class B<T, U> {}
function foo<X, Y>(...args: [B<X, Z0>, B<Z0, Z1>, B<Z1, Z2>, ..., B<ZN, Y>]) {}
foo<string, number>(new B<string, number>, new B<number, boolean>, new B<boolean, number>); // Correct
foo<string, number>(new B<string, number, new B<number, boolean>); // Incorrect
foo<string, number>(new B<string, number>, new B<boolean, number>); // Incorrect
What should I replace the "[B<X, Z0>, B<Z0, Z1>, B<Z1, Z2>, ..., B<ZN, Y>]
" with to make this work? Is this even possible?
Thank you!