diff --git a/src/ReadonlyRecord.ts b/src/ReadonlyRecord.ts index a54b22fbf..d00d2835b 100644 --- a/src/ReadonlyRecord.ts +++ b/src/ReadonlyRecord.ts @@ -159,12 +159,13 @@ export function insertAt(k: string, a: A): (r: ReadonlyRecord) => const _hasOwnProperty = Object.prototype.hasOwnProperty -// TODO: rename to avoid #1249? +// TODO: rename in v3 to avoid #1249 /** * @since 2.5.0 */ -export function hasOwnProperty(k: string, r: ReadonlyRecord): k is K { - return _hasOwnProperty.call(r, k) +export function hasOwnProperty(k: string, r: ReadonlyRecord): k is K +export function hasOwnProperty(this: any, k: string, r?: ReadonlyRecord): k is K { + return _hasOwnProperty.call(r === undefined ? this : r, k) } /** diff --git a/test/ReadonlyRecord.ts b/test/ReadonlyRecord.ts index fffe94ba5..17822b0d1 100644 --- a/test/ReadonlyRecord.ts +++ b/test/ReadonlyRecord.ts @@ -407,6 +407,11 @@ describe('ReadonlyRecord', () => { const x: _.ReadonlyRecord = { a: 1 } assert.deepStrictEqual(_.hasOwnProperty('a', x), true) assert.deepStrictEqual(_.hasOwnProperty('b', x), false) + // TODO: remove in v3 + // #1249 + const hasOwnProperty: any = _.hasOwnProperty + assert.deepStrictEqual(hasOwnProperty.call(x, 'a'), true) + assert.deepStrictEqual(hasOwnProperty.call(x, 'b'), false) }) it('updateAt', () => {