hasOwn
function hasOwn<T, K>(obj, prop): obj is T & Record<K, unknown>;
A type utility function to check if the provided object has the prop, and provide a proper type to workaround Typescript's limitation
Type Parameters
| Type Parameter |
|---|
T extends object |
K extends PropertyKey |
Parameters
| Parameter | Type | Description |
|---|---|---|
obj | T | The object to check |
prop | K | The prop to be used for the checking |
Returns
obj is T & Record<K, unknown>