Explain to me what keyof typeof
means in TypeScript
Example:
enum ColorsEnum {
white="#ffffff",
black = '#000000',
}
type Colors = keyof typeof ColorsEnum;
The last row is equivalent to:
type Colors = "white" | "black"
But how does it work?
I would expect typeof ColorsEnum
to return something like "Object"
and then keyof "Object"
to not do anything interesting. But I am obviously wrong.