In Typescript, arrays are typed as T[] (or Array<T>), [T] means a tuple where the first element is type T. The example didn't catch this as at runtime they are represented as arrays (and therefore iterable the same way), however assignments are typechecked so the array length and element types are restricted to what is defined in the tuple.
In Typescript, arrays are typed as
T[]
(orArray<T>
),[T]
means a tuple where the first element is typeT
. The example didn't catch this as at runtime they are represented as arrays (and therefore iterable the same way), however assignments are typechecked so the array length and element types are restricted to what is defined in the tuple.