When passing a generic multidimensional array T[][] (or rest params of T[]), TypeScript appears to expect the subsequent arrays to be a superset of the types in the first array.
function abc<T>(values: T[][]): T[] {
return values[0];
}
abc([[1], ['string'], [2], [3]]) // Error: Type 'string' is not assignable to type 'number'.
What is the reason for this behavior? Is there a way to make it infer the type as (number | string)[][]?