isguard-ts
    Preparing search index...

    Function isIndexRecord

    • Creates an IndexRecordTypeGuard that checks that the value is an index record with the specified value type.

      Can be shortened with TypeGuard.indexRecord.

      Type Parameters

      • T

        The value type for all keys

      Parameters

      • isValue: TypeGuard<T>

        The type guard for the values

      Returns IndexRecordTypeGuard<T>

      A type guard for Record<PropertyKey, T>

      const isNumberRecord = isIndexRecord(isNumber); // or isNumber.indexRecord()
      // ^? TypeGuard<Record<PropertyKey, number>>

      isNumberRecord({ a: 1, b: 2 }); // true
      isNumberRecord({ a: 1, b: "2" }); // false