I stumbled across a problem I have which is that I need to iterate over generic enum Types. I'm trying to get the values of the enum Type.
Typescript error in GetPaths function in the for loop parameters:
"'T' only refers to a type, but is being used as a value here"
export enum ERoutingPaths {
Home = "/",
About = "/About"
}
export enum EGamePaths {
Snake = "/Snake",
Maze = "/Maze",
}
function GetPaths<T extends ERoutingPaths | EGamePaths>():any {
let result = "";
for (let item in Object.values(T)) {
result += item + "|";
}
return result;
}
How can I make a function which allows me to iterate over a generic enum type if I would have other enum types aswell ?