Say, I have an array const colors = ['R', 'G', 'B'] (or object const colors = {R: 'R', G: 'G', B: 'B'} which will also do). Considering typescript enums transpiled into objects, if I'm not missing anything. Is there a way to parse above array (or object) into enum dynamically?
E.g. something like (non-working pseudo-code sample for the sake of example):
type Color = colors.reduce((palette, color) => palette | color)
or
enum Color = colors.reduce((palette, color) => (palette[color] = color, palette), enum)
The whole idea behind is to turn long list of string values into enum, without hardcoding miles long type definition, like:
type Color = 'R' | 'G' | 'B' .. /* followed by gazillion more color values */