To find the union of types of values associated with numeric keys, the number
type must be used.
const animals = ['dog', 'cat', 'hen'] as const
type Animal = typeof animals[number] // type Animal = "dog" | "cat" | "hen"
But what exactly is this number
? Is it a type
, constant
, or some other keyword
?