On an angular 12 app I have the enum:
export enum Policy {
Admin,
Manager
}
I try to define a variable of type Policy as follows:
let policy: Policy = Policy[route.data.policy as string];
The type of route.data.policy is any. But I get the error:
Element implicitly has an 'any' type because index expression is not of type 'number'.
How can to parse the value of route.data.policy which would be 'Admin' or 'Manager' to enum?
let policy: Policy = Policy[route.data.policy as keyof typeof Policy];TS Playground