Syntax
Offset access
An offset access is the type of one element of another type: the type, then
the key in square brackets (T[K]).
The element under the string key offset.
T['offset']
resultTypeLang\Type\TypeOffsetAccessTypeNode
The element under a key of the type U.
T[U]
resultTypeLang\Type\TypeOffsetAccessTypeNode
An element of a shape under a numeric key.
array{int, string}[0]
resultTypeLang\Type\TypeOffsetAccessTypeNode
A generic with a shape as the key.
T<U>[object{key: int, ...}]
resultTypeLang\Type\TypeOffsetAccessTypeNode
The key is enclosed in single brackets.
Collection[[Some]]
errorMalformedSyntaxException A type or "]" is expected after "["
The type comes first, the key follows it.
Collection['key']{key: string}
errorUnexpectedTokenException Unexpected "{"
Offsets chain with each other and with the list syntax: each suffix applies to the result of the previous one.
T['a'][]['b']
resultTypeLang\Type\TypeOffsetAccessTypeNode