Simplifying Union Type Matching in TypeScript

Is there an easier way of making something like this:
export type IsHumanModalClosed = {
  _tag: 'closed'
}

export type IsHumanModalOpened = {
  _tag: 'open'
  challenge: string
}

export type IsHumanModalState = IsHumanModalClosed | IsHumanModalOpened

const isHumanModalStateMatcher = <T>(params: {
  closed: (closed: IsHumanModalClosed) => T
  open: (open: IsHumanModalOpened) => T
}) =>
  pipe(
    Match.type<IsHumanModalState>(),
    Match.tag('closed', params.closed),
    Match.tag('open', params.open),
    Match.exhaustive
  )


I hate that I have do do the following:
<T>(params: {
  closed: (closed: IsHumanModalClosed) => T
  open: (open: IsHumanModalOpened) => T
}) =>
Was this page helpful?