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
30 changes: 0 additions & 30 deletions flow-typed/npm/promise_v8.x.x.js

This file was deleted.

30 changes: 9 additions & 21 deletions packages/react-native/Libraries/Core/polyfillPromise.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,17 @@

'use strict';

const {polyfillGlobal} = require('../Utilities/PolyfillFunctions');

/**
* Set up Promise. The native Promise implementation throws the following error:
* ERROR: Event loop not supported.
*
* If you don't need these polyfills, don't use InitializeCore; just directly
* require the modules you need from InitializeCore for setup.
* Set up Promise. All supported JS engines provide a spec-compliant native
* Promise implementation, so it no longer needs to be polyfilled. In DEV,
* enable unhandled rejection tracking where the engine supports it.
*/

// If global.Promise is provided by Hermes, we are confident that it can provide
// all the methods needed by React Native, so we can directly use it.
if (global?.HermesInternal?.hasPromise?.()) {
const HermesPromise = global.Promise;

if (__DEV__) {
if (typeof HermesPromise !== 'function') {
console.error('HermesPromise does not exist');
}
global.HermesInternal?.enablePromiseRejectionTracker?.(
require('../promiseRejectionTrackingOptions').default,
);
if (__DEV__) {
if (typeof global.Promise !== 'function') {
console.error('Promise does not exist');
}
} else {
polyfillGlobal('Promise', () => require('../Promise').default);
global.HermesInternal?.enablePromiseRejectionTracker?.(
require('../promiseRejectionTrackingOptions').default,
);
}
23 changes: 0 additions & 23 deletions packages/react-native/Libraries/Promise.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
* @format
*/

import typeof {enable} from 'promise/setimmediate/rejection-tracking';

import ExceptionsManager from './Core/ExceptionsManager';

const rejectionTrackingOptions: NonNullable<Parameters<enable>[0]> = {
type RejectionTrackingOptions = {
whitelist?: ?Array<unknown>,
allRejections?: ?boolean,
onUnhandled?: ?(number, unknown) => void,
onHandled?: ?(number, unknown) => void,
};

const rejectionTrackingOptions: RejectionTrackingOptions = {
allRejections: true,
onHandled: id => {
const warning =
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
"metro-source-map": "^0.87.0",
"nullthrows": "^1.1.1",
"pretty-format": "^29.7.0",
"promise": "^8.3.0",
"react-devtools-core": "^6.1.5",
"react-refresh": "^0.14.0",
"regenerator-runtime": "^0.13.2",
Expand Down
Loading