Creates a RecordTypeGuard that checks that the value has the specified keys with the specified value type.
RecordTypeGuard
Array of keys for the record
The value type for all keys
The keys that must be present in the record
The type guard for the values
A type guard for Record<K, V>
Record<K, V>
const timeUnits = ["second", "minute", "hour"] as const;const isTimeRecord = isRecord(timeUnits, isNumber);// ^? TypeGuard<Record<"second" | "minute" | "hour", number>>isTimeRecord({ second: 1, minute: 2, hour: 3 }); // trueisTimeRecord({ second: 1 }); // false Copy
const timeUnits = ["second", "minute", "hour"] as const;const isTimeRecord = isRecord(timeUnits, isNumber);// ^? TypeGuard<Record<"second" | "minute" | "hour", number>>isTimeRecord({ second: 1, minute: 2, hour: 3 }); // trueisTimeRecord({ second: 1 }); // false
Creates a
RecordTypeGuardthat checks that the value has the specified keys with the specified value type.