mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ff4b33672a
Summary: Changelog: [Internal] This diff add a flow libdefs for the `HermesInternalType` to type `HermesInternal` as the first accurately typed `global` property, and filled all the type holes. Reviewed By: yungsters Differential Revision: D29986749 fbshipit-source-id: a94be7919f989b5085f6b264e55145a85020fea9
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict
|
|
* @format
|
|
*/
|
|
|
|
'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.
|
|
*/
|
|
|
|
// 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,
|
|
);
|
|
}
|
|
} else {
|
|
polyfillGlobal('Promise', () => require('../Promise'));
|
|
}
|