Here is some TypeScript code to consider:
function concatTuples<T>(first: [...T[]], second: [...T[]]): [...T[]] {
return [...first, ...second];
}
const result = concatTuples([0, 1], [2, 3]);
This function concatenates tuples. The current challenge is that the length of the returned tuple is not known beforehand.
The current type of result
: number[]
.
I would like the type to be: [number, number, number, number]
.
It is desired that the size of the returned tuple/array is dynamically determined based on the function's arguments.
Is there a way to achieve this? After reviewing the documentation, no direct solution was found.