I couldn't find this in the similar questions.
I'm trying to type a tuple with an unknown number of elements.
I know Typescript 4 added support for Variadic Tuples
I can't wrap my head around it although I read the docs
The example is plain:
function map<S, T, U, Z>(values: [S, T, U], mapper: (s: S, t: T, u: U) => Z): Z {
return mapper(...values);
}
const v = map([1, 'hello', 3], (s, t, u) => `${s + t + u}`);
This works for 3 elements but not for any (dynamic) number of elements.
How can I type this in a generic way for any number of elements?
Thanks!