mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: The Flow team is improving the way Flow infers type for primitive literals. This diff prepares the codebase for the new behavior by adding type annotations, or annotations of the form `'abc' as const`. Changelog: [internal] Reviewed By: marcoww6 Differential Revision: D75188179 fbshipit-source-id: be50990f23f79cf2d8dae7576af5190218adcafe
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and 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-local
|
|
* @format
|
|
*/
|
|
|
|
import Platform from '../Utilities/Platform';
|
|
|
|
declare var console: {[string]: $FlowFixMe};
|
|
|
|
/**
|
|
* Sets up developer tools for React Native.
|
|
* You can use this module directly, or just require InitializeCore.
|
|
*/
|
|
if (__DEV__) {
|
|
if (!Platform.isTesting) {
|
|
const HMRClient = require('../Utilities/HMRClient').default;
|
|
|
|
// TODO(T214991636): Remove legacy Metro log forwarding
|
|
if (console._isPolyfilled) {
|
|
// We assume full control over the console and send JavaScript logs to Metro.
|
|
(
|
|
[
|
|
'trace',
|
|
'info',
|
|
'warn',
|
|
'error',
|
|
'log',
|
|
'group',
|
|
'groupCollapsed',
|
|
'groupEnd',
|
|
'debug',
|
|
] as const
|
|
).forEach(level => {
|
|
const originalFunction = console[level];
|
|
console[level] = function (...args: $ReadOnlyArray<mixed>) {
|
|
HMRClient.log(level, args);
|
|
originalFunction.apply(console, args);
|
|
};
|
|
});
|
|
}
|
|
}
|
|
|
|
require('./setUpReactRefresh');
|
|
|
|
global[`${global.__METRO_GLOBAL_PREFIX__ ?? ''}__loadBundleAsync`] =
|
|
require('./Devtools/loadBundleFromServer').default;
|
|
}
|