Type guard that narrows an array to a non-empty tuple type. After this check, TypeScript knows arr[0] is defined.
arr[0]
if (!isNonEmptyArray(items)) { return;}// items[0] is now typed as T (not T | undefined)const first = items[0]; Copy
if (!isNonEmptyArray(items)) { return;}// items[0] is now typed as T (not T | undefined)const first = items[0];
Type guard that narrows an array to a non-empty tuple type. After this check, TypeScript knows
arr[0]is defined.