I’m really confused about this now. I’m pretty sure that
let x:SomeType[] = []
is equivalent to
let x: Array<SomeType> = []
but is
let x:[SomeType] = []
also equivalent and correct?
No. [SomeType]
represents a tuple type, i.e., an array with exactly one element of SomeType
[string, number]
, for example, would match an array like ["test", 0]
source:
https://stackoverflow.com/questions/63625736/is-interface-a-valid-array-definition-in-typescript