Type guard that narrows an array to a non-empty tuple-like type.
Array to test. null and undefined are treated as empty.
null
undefined
true when items is non-null and has at least one element; narrows the type to a non-empty tuple.
true
items
const values: number[] = [1, 2, 3];if (isPopulatedArray(values)) { // values: [number, ...number[]]}isPopulatedArray([]); // falseisPopulatedArray(null); // false Copy
const values: number[] = [1, 2, 3];if (isPopulatedArray(values)) { // values: [number, ...number[]]}isPopulatedArray([]); // falseisPopulatedArray(null); // false
Type guard that narrows an array to a non-empty tuple-like type.