Function assertIsBoolean

Asserts that the input is a boolean.

An error if the input is not a boolean.

const fn = (x: unknown) => {
assertIsBoolean(x);
return x; // x has inferred type boolean
};
  • Parameters

    • x: unknown

      The input to be asserted.

    Returns asserts x is boolean