Function guardEitherIn

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

    Example

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

    Type Parameters

    Parameters

    • guards: readonly [Guards]

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

Generated using TypeDoc