Skip to content

NonEmptyList

NonEmptyList<A> = readonly [A, ...A[]]

Defined in: Types/NonEmptyList.ts:14

A list that is guaranteed to have at least one element. Useful for ensuring functions receive non-empty input and for accumulating errors in Validation.

A

const errors: NonEmptyList<string> = ["First error", "Second error"];

// TypeScript ensures at least one element:
const invalid: NonEmptyList<string> = []; // Error!