I have been struggling to find adequate information in the Typescript handbook on how to correctly utilize string enums.
Here is my example:
enum ICE_CREAM {
strawberry = "STRAWBERRY",
vanilla = "VANILLA"
}
type TORDER = {
greetings: string,
flavor: ICE_CREAM
}
const mockData: TORDER = {
greetings: "Hello",
flavor: "VANILLA",
}
This results in an error message stating:
'"VANILLA"' is not assignable to type 'ICE_CREAM'.(2322)
My goal is to ensure that the value of the "flavor" key in the data sent by my backend matches one of the values defined in my ICE_CREAM
string enum. Can you point out what I may be doing incorrectly?