I am unsure about what should be the appropriate type for the function that retrieves an enum member in my code. Here is the current version of my code:
interface Letter {
character: string,
color: Function
}
enum Color {
Green,
Yellow,
Grey
}
const letter_1: Letter = {
character: playerInput[0],
color: () => {
if (letter_1.character === playerInput[0])
return Color.Green;
else {
for (let i = 0; i < playerInput.length; i ++) {
if (letter_1.character === playerInput[i])
return Color.Yellow;
}
}
return Color.Grey;
}
};
In the Letter
interface, I have currently defined the type for color()
as Function
. However, I suspect there might be a more suitable type for it that I am not aware of.