The type of the key to check, must extend PropertyKey (string | number | symbol)
The type of the record (object), must extend UnknownRecord
true
if key
is an own property of obj
, false
otherwise. When
true
, TypeScript narrows the key type to be a valid key of the object.
Type guard that checks if a key exists as an own property in an object.
This function is similar to
hasKey()
but with reversed parameter order and different type narrowing behavior. WhilehasKey()
narrows the object type,keyIsIn()
narrows the key type to be a valid key of the given object.Type Narrowing Behavior:
K & keyof R
)Implementation: Uses
Object.hasOwn()
to check for own properties (not inherited).