Function: hasProperty()
function hasProperty<K>(
value: unknown,
property: K
): value is Record<K, unknown> & UnknownRecord;
Defined in: shared/utils/typeGuards.ts:90
Checks if a value exposes a specific own property.
Type Parametersโ
Kโ
K extends PropertyKey
Property key that must exist on the value.
Parametersโ
valueโ
unknown
Value to evaluate as an object.
propertyโ
K
Property name that must be present on the value.
Returnsโ
value is Record<K, unknown> & UnknownRecord
true when the property exists directly on the value.
Exampleโ
if (hasProperty(obj, "foo")) {
// obj has the 'foo' property
}