Type alias NonEmptyArray<T>

NonEmptyArray<T>: [T, ...T[]]

Represents a non-empty array of elements of type T. Ensures that the array has at least one item.

Type Parameters

  • T

Example

const valid: NonEmptyArray<number> = [1]; // ✅
const invalid: NonEmptyArray<number> = []; // ❌ Type error