UtilOptional

isNonEmptyArray

Type guard for an array with at least one element, so [0] is typed T.

Usage

import { isNonEmptyArray } from 'ngwr/utils';

if (isNonEmptyArray(rows)) {
  highlight(rows[0]); // Row, not Row | undefined
}

API

NameDescriptionTypeDefault
isNonEmptyArray(value)Narrows to [T, ...T[]], so index 0 is not nullable. Accepts a null or undefined list too.<T>(value: Maybe<T[]>) => value is [T, ...T[]]—

See also