as const freezes a value’s shape and keeps literal types. With const COLORS = {...} as const, keyof typeof COLORS is a union of color names and typeof COLORS[Name] is a union of the hex codes. Use these to type a lookup function that returns precise values.
const MAP = { a: 1, b: 2 } as const;
type Key = keyof typeof MAP; // 'a' | 'b'
type Val = (typeof MAP)[Key]; // 1 | 2
Return the exact hex string for the given color name.
Map color names to hex codes with precise types.