@bodil/core - v0.4.3
    Preparing search index...

    Function assertNever

    • Assert that a type is never when type checking. Throws an unreachable exception if it's reached at runtime. This is meant as an exhaustiveness check.

      Type Parameters

      • T extends never

      Parameters

      • _value: T

      Returns T

      type State = "on" | "off";
      function checkState(state: State) {
      if (state === "on") {
      console.log("it's on");
      } else if (state === "off") {
      console.log("it's off");
      } else {
      // this would fail to type check if you
      // haven't tested all valid `State` values
      // in the above if statement:
      assertNever<typeof state>();
      }
      }