Effect CommunityEC
Effect Community2y ago
29 replies
nemmind1

Compiler Error Suggestion for `Match.orElse` in TypeScript

Hi! Match.exhaustive throws a compiler error, when there is a non coveraged case. I think the same way Match.orElse should throw compile error when there is no other option, what do you think?

import { Match, pipe, Predicate } from 'effect';

const match = pipe(
  Match.type<string | number>(),
  Match.when(Predicate.isString, () => 1 as const),
  Match.when(Predicate.isNumber, () => 2 as const),
  // This should never happens, so should throw a compile error
  Match.orElse((_never_) => 3 as const)
);
Was this page helpful?