I have the next code:
enum MyEnum {
Colors = 'AreColors',
Cars = 'AreCars',
}
const menuTitle = ((obj: MyEnum) => {
const newObj = {};
Object.keys(obj).forEach((x) => {
newObj[obj[x]] = x;
});
return newObj;
});
Here i want to change the enum keys in place of enum values.
Doing this i get Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'
here newObj[obj[x]] = x;
.
Why the issue appears and how to solve?