From 86ff90735533280d9192a1d77db3fe65d7fbecb0 Mon Sep 17 00:00:00 2001 From: Asmitha B Date: Mon, 12 Jan 2026 20:30:01 +0530 Subject: [PATCH] Add type guard to objectIs utility --- packages/shared/objectIs.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/shared/objectIs.js b/packages/shared/objectIs.js index 608adfc3bcf..cf7ee2d1d88 100644 --- a/packages/shared/objectIs.js +++ b/packages/shared/objectIs.js @@ -11,12 +11,18 @@ * inlined Object.is polyfill to avoid requiring consumers ship their own * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is */ -function is(x: any, y: any) { +function is(x, y) { + if (typeof x !== typeof y) { + return false; + } + return ( - (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare + (x === y && (x !== 0 || 1 / x === 1 / y)) || + (x !== x && y !== y) ); } + const objectIs: (x: any, y: any) => boolean = // $FlowFixMe[method-unbinding] typeof Object.is === 'function' ? Object.is : is;