UtilUpdated in v16Optional

wrIsNonEmptyArray

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

Usage

import { wrIsNonEmptyArray } from 'ngwr/utils';

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

API

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

See also