API reference / @evolu/common / Assert / assertNonEmptyReadonlyArray
Variable: assertNonEmptyReadonlyArray()
const assertNonEmptyReadonlyArray: <T>(arr, message?) => asserts arr is readonly [T, ...T[]];
Defined in: packages/common/src/Assert.ts:87
Asserts that a readonly array is non-empty.
Ensures the provided readonly array has at least one element, helping TypeScript infer non-emptiness when this is logically guaranteed but not statically known.
Example
assertNonEmptyReadonlyArray([1, 2, 3]); // no-op
assertNonEmptyReadonlyArray([]); // throws Error
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
arr | ReadonlyArray <T > |
message? | string |
Returns
asserts arr is readonly [T, ...T[]]