You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because a tuple of length n is an anonymous type that has properties 0, ... n - 1, and which effectively extends an array of the union of all element types. Since it's a subtype of Array, it gets an index signature, whose output type is the union of all element types.
TypeScript knows
y
is astring
. However, if I ask forx[2]
, TypeScript tells me it isstring | number
. Why is this? I expected it not to compile.The text was updated successfully, but these errors were encountered: