Function isRecord

  • Checks whether a value is a generic key / value object / Record<string, unknown>.

    A record in this context means:

    • typeof value === 'object'
    • value is not null
    • value is not an array

    Unlike isObject, this function does not attempt to preserve the original object type. All successful results narrow to Record<string, unknown> making the returned value safe for key-indexed access but without any knowledge of property names or expected value types.

    This is useful when processing untyped JSON-like data structures, dynamic configuration blocks, response bodies, or any case where a dictionary-style object is expected rather than a typed interface value.

    Contrast With:

    • isObject → preserves known object types where possible; use when typing should remain intact.
    • isPlainObject → narrows to plain JSON objects only (no prototypes, no class instances).
    • isRecord() → always narrows to a dictionary-style record for keyed lookup.

    Parameters

    • value: unknown

      Any value to test.

    Returns value is Record<string, unknown>

    True if the value is an object that is neither null nor an array.