TypeScript Mapped Types
Hey. I have this type which uses mapped types to generate this other type. It works a little bit, but I'd like it to generate a different type of type union.
1 Reply
The type of
renderer.send
is (channel: "test2" | "test1", ...args: [_: Electron.IpcMainEvent, __: number] | [_: Electron.IpcMainEvent, __: string]) => void
.
It's nice but it could be improved. Is there any way to make it ((channel: "test1", ...args: [_: Electron.IpcMainEvent, __: number]) => void) | ((channel: "test2", ...args: [_: Electron.IpcMainEvent, __: string]) => void)
?
I ended up mapping the types into an object first, then just grab each of its values and putting it into a union and it worked fine 👍