Generic key for either object or array.
Type to represent the type of the key in an ReadOnlyCollection. It automatically omits symbol keys from objects, and uses number for arrays with dynamic length.
symbol
number
length
const array = [1, 2, 3] as const;const object = { "🟢": "🟩" } as const;const arrayKey: KeyOf<typeof array> = 0;const objectKey: KeyOf<typeof object> = "🟢"; Copy
const array = [1, 2, 3] as const;const object = { "🟢": "🟩" } as const;const arrayKey: KeyOf<typeof array> = 0;const objectKey: KeyOf<typeof object> = "🟢";
ReadOnlyCollection
The input ReadOnlyCollection.
Generic key for either object or array.
Remarks
Type to represent the type of the key in an ReadOnlyCollection. It automatically omits
symbol
keys from objects, and usesnumber
for arrays with dynamiclength
.Example
See
ReadOnlyCollection