Function guardRecord

  • Given a Type Guard, returns a Type Guard that checks if the given value is a Record and all its entries match the given Type Guard.

    Example

    import { guardRecord } from "type-guard-helpers"

    const test = {} as unknown;
    const isTranslation = guardRecord(
    (val): val is { readonly translation: string } => !!val.translation
    );

    if (isTranslation(test)) {
    test; // { readonly translation: string; }
    }

    Type Parameters

    • Guard extends AnyTypeGuard<Record<string, unknown>, Record<string, unknown>>

    Parameters

    • guard: Guard

    Returns TypeGuardFn<unknown, GuardType<Guard>>

Generated using TypeDoc