I'm attempting to achieve a scenario similar to the code below:
enum Color
{
RED="RED",
GREEN="GREEN",
BLUE="BLUE"
}
function setColor(color:Color)
{
}
However, when I attempt to call the function like this:
setColor("RED"),
I encounter the error message:
Argument of type '"RED"' is not assignable to parameter of type 'Color'.ts(2345),
I am aware that I can use
setColor("Red" as Color)
,
but my preference is for "RED" to be auto-completed as I type. Is there a way to achieve this functionality?