SO, I have a function, that takes values of object and return another object that use those values as keys. It looks something like this:
function fn(actions) {
return keys.reduce((acc, m) => {
const name = actions[m]
acc[name] = () => { /* some function */}
return acc
}, {})
}
Now, somehow I want to type it so that when I call it
res = fn({"something": "go", "something else": "run"})
res. // ...
autocomplete would work to suggest that there are indeed 2 methods can be invoked "go" and "run".
So basically I expect res to have type of { [key in 'go' | 'run']: Function }.
Is that possible to achieve with TS?