If I have an object with many keys and each value in each key has different value type
type keys = 'typeA' | 'typeB' | ... | 'typeZZZ'
const obj = {
'typeA': typeA,
'typeB': typB,
...
'typeZZZ': typeZZZ
}
const destruct = (key: keys): /* what's the return type I can specify? */ => {
return obj[key] // <- how should I narrow type here?
}
const typeA = destruct('typeA') // <- I want this value type to be `typeA` without using as or if statement
Is it possible to do it?