enum Colors { 'black', 'brown', 'red', 'orange', 'yellow', 'green', 'blue', 'violet', 'grey', 'white' } function EnumKeys<T>(enumType: T): (keyof T)[] { return (Object.keys(enumType) as Array<keyof T>) .filter(value => isNaN(Number(value)) !== false); } export const COLORS = EnumKeys(Colors) // COLORS = ['black','brown','red','orange','yellow','green','blue','violet','grey','white']
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter