I'm having a problem properly typing an object key to an enum. This is essentially what I have:
enum ItemTypes {
WOOD,
STONE
}
interface Item {
owned: number,
max: number
}
const stockpile: {[key in ItemTypes]: Item} = {}
I'm getting an error where stockpile is expecting the itemType enums to already exist within stockpile
Doing this works:
const stockpile: { [key: string]: Item } = {}
However, I would prefer it to be better typed as well as being able to export the enum to be used elsewhere. How would I go about this?