There is a function that takes in a configuration object containing color definitions.
For example:
useColors({
colors: {
RED: { hex: 0xff0000 },
GREEN: { hex: 0x00ff00 },
BLUE: { hex: 0x0000ff }
},
doSomethingWithColor(getColor) {
getColor('RED') // should accept "RED" | "GREEN" | "BLUE"
}
})
The function also accepts another function doSomethingWithColor
, and the callback parameter type of this function should be a combination of the colors defined in the configuration object itself.
Can TypeScript achieve this?