Reputation: 3
What is the difference between this two type definitions?
type objectArray = [object]
type objectArray = object[]
Upvotes: 0
Views: 817
Reputation: 371128
[object]
is a tuple. It's the type of an array with a single value in it, and the value must be an object
.
object[]
is the same as Array<object>
. It's the type of an array with any number of values, where any such values must be object
.
All tuples are arrays, but a tuple is a more restrictive type of array, with a specified number of elements.
Upvotes: 1