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>} Copy
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>}
The value to be asserted.
Asserts that the input is a non-empty array.
Throws
An error if the input is not an array or it is empty.
Example