Here is what I'm trying to achieve
function Enum<T extends string>(arr: T[]): Record<T, T> {
return arr.reduce((next, key, index) => {
next[key] = key
return next
}, {} as Record<T, T>)
}
const Codes = Enum([
'foo',
'bar'
])
I want typescript to know that Codes.foo is only 'foo'. Right now it thinks it can be 'foo' | 'bar'
I'm aware of Enums. This is more of curiosity question.