While experimenting with TypeScript type manipulation, I attempted to modify the type provided below
type setOfFunctions = [{
name: 'hi',
fun: () => number
}, {
name: 'world',
fun: () => string
}]
in order to achieve the following desired type
type MyFunctions = {
hi: () => number,
world: () => string
}
I made an attempt using the following type
type MyFunctions = {
[key in setOfFunctions[number]["name"]] : setOfFunctions[number]["fun"]
}
However, this resulted in
type MyFunctions = {
hi: (() => number) | (() => string);
world: (() => number) | (() => string);
}