90s_dev 21 hours ago

Tuples: {number, string}

Arrays: {number}

How does it disambiguate it? Are single-element tuples just never used in practice? To be fair, maybe the only time I've had to use them in TypeScript is via Parameters<T>

2
hisham_hm 8 hours ago

In our experience, single-element tuples are just never used in practice. There has been some discussion on how to add syntax for them, but I think it's more of a desire for orthogonality than for a practical need.

90s_dev 8 hours ago

Yeah I can't imagine any scenario where it's not just a value or an array of values that happens to have only one value right now.

johnisgood 10 hours ago

Now I am curious what {number, string, number} would be considered as.

hisham_hm 8 hours ago

it's a three element tuple.

johnisgood 8 hours ago

That was my guess, just as {n, n, n, n} would be a four element tuple, right?