Currently tuples are only used when all source arrays have the same length and combining the shapes of the array would lose type information. E.g. you can end up with [["a", 1], ["b", 2]] is inferred to Array<[string, number]>, but [[1, 2], [3, 4]] is inferred as number[][].
We already have the hint use_type: "map". We should similarly have use_type: "tuple" and with that make it possible to end up with types like [string, string] and [number, number, number?].
Currently tuples are only used when all source arrays have the same length and combining the shapes of the array would lose type information. E.g. you can end up with
[["a", 1], ["b", 2]]
is inferred toArray<[string, number]>
, but[[1, 2], [3, 4]]
is inferred asnumber[][]
.We already have the hint
use_type: "map"
. We should similarly haveuse_type: "tuple"
and with that make it possible to end up with types like[string, string]
and[number, number, number?]
.