You should be able to do table.freeze on valuetype and get rid of the metatable stuff. Also I don’t think you can use variables when defining types.
Here’s how I’d do it
export type EquipmentEnum = number
return table.freeze({
Primary = 1,
Secondary = 2,
})
then
type Data = {[EquipmentDataType.EquipmentEnum]: number}
type Data = {
[EquipmentDataType.Primary | EquipmentDataType.Secondary]: number,
}
This removes the error, but if you were hoping to have only two defined indexes in the table whilst also not knowing the indexes until the table is created I’m not sure that is possible.