Function assertRecord
-
Type Parameters
- T
Parameters
- value: T
The value to validate.
OptionalerrorMsg: stringOptional message used for the thrown TypeError.
Returns asserts value is T & Record<PropertyKey, unknown>
The value to validate.
OptionalerrorMsg: string
Optional message used for the thrown TypeError.
Asserts that a value is a non-null, non-array object that can be treated as a string-keyed record.
Unlike isRecord, this function does not narrow the value to a generic indexable structure. Instead, it preserves the existing static type of the variable. This makes it ideal for validating option objects or interface-based inputs where all properties may be optional.
Use this function when: