UNPKG

ts-has-own-property

Version:

Fix for Object.hasOwnProperty, which normally just returns a boolean, which is not good when you care about strong typing

9 lines (6 loc) 311 B
const _hasOwnProperty = Object.prototype.hasOwnProperty; export const hasOwnProperty = <TObject extends object, TProperty extends PropertyKey>( object: TObject, property: TProperty ): object is TObject & Record<TProperty, unknown> => _hasOwnProperty.call(object, property); export default hasOwnProperty;