Skip to main content

Function: hasProperties()

hasProperties<K>(value: unknown, properties: readonly K[]): value is Record<K, unknown>

Defined in: shared/utils/typeGuards.ts:57

Determines if an object contains all specified properties.

Type Parametersโ€‹

Kโ€‹

K extends PropertyKey

The type of property keys to check for.

Parametersโ€‹

valueโ€‹

unknown

The value to check.

propertiesโ€‹

readonly K[]

An array of property keys that must be present on the value.

Returnsโ€‹

value is Record<K, unknown>

True if value is an object containing all specified properties; otherwise, false.

Exampleโ€‹

if (hasProperties(obj, ["foo", "bar"])) {
// obj has both 'foo' and 'bar' properties
}