Function guardEither

  • Given one or multiple Type Guards as arguments, returns a Type Guard to check if a value matches at least one of the given Type Guard(s). Same as guardEitherIn, but accepts multiple arguments instead of a single array

    Example

    import { isNull,  match, guardEither, isTypeString } from 'type-guard-helpers';
    const isStringOrNull = guardEither(isNull, isTypeString);
    const test = {} as unknown;
    if (isStringOrNull(test)) {
    test; // string || null
    }

    Type Parameters

    Parameters

    • Rest ...guards: readonly [Guards]

    Returns TypeGuardFn<GuardTypeInput<Guards[number]>, GuardType<Guards[number]>>

Generated using TypeDoc