Function isObject

    • Type Parameters

      • T extends object

      Parameters

      • value: T

      Returns value is T

    • Runtime check for whether a value is an object:

      - typeof === 'object'
      - not null
      - not an array

      This function performs type narrowing. If the check succeeds, TypeScript refines the type of value to T, allowing known object types (interfaces, classes, mapped structures) to retain their original shape.

      Type Behavior:

      • When called with a value that already has a specific object type (interface or shaped object), that type is preserved after narrowing. Property access remains fully typed.

      • When called with unknown, any, or an untyped object literal, T becomes object, ensuring only that a non-null object exists. No indexing or deep property inference is provided in this case.

      In other words:

      - Known object typeremains that type (preferred behavior)
      - Unknown / untypednarrows only to `object`

      Use this when you want runtime object validation and want to preserve typing when a value is already known to be a specific object type. If you instead need to retain the declared type regardless of narrowing, use assertObject. If you need indexable key / value access use a dedicated record check such as isRecord or isPlainObject.

      Parameters

      • value: unknown

        Any value to check.

      Returns value is object

      True if the value is a non-null object and not an array.