Why is this param type not assignable to the designated?

github logo ・1 min read

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…

twitter logo DISCUSS
Classic DEV Post from Aug 30

SELECT Post FROM Stack Overflow Questions WHERE Topic = "git" ORDER BY Votes DESC;

Birowsky profile image