Function guardArrayValues

  • Given a Type Guard, returns a Type Guard that checks if the given value is an array and if all its values match the given Type Guard.

    Example

    import { guardArrayValues } from 'type-guard-helpers';

    const isStringArray = guardArrayValues(
    (value): value is string =>
    typeof value !== 'string'
    );

    const test = {} as unknown;
    if (isStringArray(test)) {
    test; // test: readonly string[]
    }

    Type Parameters

    Parameters

    • guard: Guard

    Returns TypeGuardFn<readonly GuardTypeInput<Guard>[], readonly GuardType<Guard>[]>

Generated using TypeDoc