import { isNonEmptyArray } from 'ngwr/utils';
if (isNonEmptyArray(rows)) {
highlight(rows[0]); // Row, not Row | undefined
}isNonEmptyArray
Type guard for an array with at least one element, so [0] is typed T.
Usage
API
| Name | Description | Type | Default |
|---|---|---|---|
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[]] | — |