@webdeveric/utils
    Preparing search index...

    Function assertExhaustive

    • Assert that this line is unreachable, useful for exhaustive checks such as a switch covering every case of a union.

      Parameters

      • _: never
      • error: string | Error = 'Failed exhaustive check'

      Returns never

      type Direction = 'up' | 'down';

      function describe(direction: Direction): string {
      switch (direction) {
      case 'up':
      return 'Going up';
      case 'down':
      return 'Going down';
      default:
      assertExhaustive(direction); // throws if a new Direction case isn't handled above
      }
      }