Enhances a Type Guard so it can be used to check all values of an array. It also checks if the array is non-empty.
A new Type Guard that takes an array
import { isString, guardNonEmptyArray } from 'type-guard-helpers';const test = [] as unknownconst isStringArray = guardNonEmptyArray((val): val is readonly [string, ...unknown[]] => isString(val[0]))if(isStringArray(test)){ test; // test: readonly [string, ...unknown[]]}
A Type Guard for valid array values
Generated using TypeDoc
Enhances a Type Guard so it can be used to check all values of an array. It also checks if the array is non-empty.
Returns
A new Type Guard that takes an array
Example