Function assertIsNonEmptyArray

Asserts that the input is a non-empty array.

An error if the input is not an array or it is empty.

const fn = (x: number[]) => {
assertIsNonEmptyArray(x); // throws an error if x is not an array or it is empty
return x; // x has inferred type NonEmptyArray<number>
}