Function assertIsArray

Asserts that the input is an array.

An error if the input is not an array.

const fn = (x: unknown) => {
assertIsArray(x); // throws an error if x is not an array
return x; // x has inferred type Array<unknown>
};
  • Parameters

    • x: unknown

      The input to be asserted.

    Returns asserts x is unknown[]