Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './polyfills.js';
import './globals.d.ts';

export { UI as ReactNativeHarness } from './ui/index.js';
Expand Down
14 changes: 14 additions & 0 deletions packages/runtime/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Polyfills for ES2022+ features not supported by JSC (JavaScriptCore).
*
* JSC, used in React Native when Hermes is disabled, doesn't support
* Object.hasOwn (ES2022). This causes runtime errors when @vitest/expect
* v4.x initializes.
*
* This polyfill must be loaded before any code that uses Object.hasOwn.
*/

if (typeof Object.hasOwn !== 'function') {
Object.hasOwn = (obj: object, prop: PropertyKey): boolean =>
Object.prototype.hasOwnProperty.call(obj, prop);
}