What is the difference between this two type definitions?
type objectArray = [object]
type objectArray = object[]
CodePudding user response:
[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.