In Angular2 I receive data from the server as a JSON object. One of the fields is a resource type. Which can be an image, video or audio. The enum looks like:
export enum MediaType {
image,
video,
audio
}
However when I try to cast the response to an MediaType enum:
this.type = MediaType[data["type"]];
I got an error:
error TS2322: Type 'string' is not assignable to type 'MediaType'.
Any thoughts?