I'm trying to implement the suggestion here, specifically, this function:
function eventAssigner<Handlers extends Record<keyof Handlers, (e: any) => any>,
Discriminant extends keyof any>(
handlers: Handlers,
discriminant: Discriminant
) {
return <Key extends keyof Handlers>(
event: Record<Discriminant, Key> & (Parameters<Handlers[Key]>[0])
): ReturnType<Handlers[Key]> => handlers[event[discriminant]](event);
}
However, eventAssigner
is rejecting theβ¦
Top comments (0)