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.
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 valueisobject
True if the value is a non-null object and not an array.
Runtime check for whether a value is an object:
This function performs type narrowing. If the check succeeds, TypeScript refines the type of
valuetoT, 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,Tbecomesobject, ensuring only that a non-null object exists. No indexing or deep property inference is provided in this case.In other words:
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.