The Typescript handbook hasn't really given me much information on how to correctly use the 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",
}
which leads to the error Type
'"VANILLA"' is not assignable to type 'ICE_CREAM'.(2322)
My backend will send data which contains the "flavor" key and I want to make sure that its value is one of the values declared in my ICE_CREAM string enum. What am I doing wrong?