I would like to know whether the below is possible.
Based on the argument passed, recoginize the object key and access with that key.
Any solutions?
function async func(arg:'key1'|'key2'){
// fetchResult returns an object which includes {key1:'result1'} or {key2:'result2'}
const obj:{[arg]:string} = await fetchResult('url')
console.log(obj[arg])
}
await func(key1) //Expect console.log('result1')
await func(key2) //Expect console.log('result2')