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