UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

14 lines 435 B
//#region src/types/NonEmptyArray.d.ts /** * An array guaranteed to have at least one element. * The first element resolves to `T` instead of `T | undefined`. * * @template T - The type of the elements. * * @example * const a: NonEmptyArray<number> = [1, 2, 3]; // ok * const b: NonEmptyArray<number> = []; // error: empty array not allowed */ type NonEmptyArray<T> = [T, ...T[]]; //#endregion export { NonEmptyArray };