mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Summary: Changelog: [Internal] This diff add types to some of the common globals so uses of them through `global` are now typed. All the globals are marked as read-only for their intented uses. However, some of them do have write cites (mostly are in tests to deliberately set up a special test environment). Those write cites are considered as "necessary evil" and annotated as `FlowFixMe`. Reviewed By: yungsters Differential Revision: D30158145 fbshipit-source-id: 93a99063361a4b7a1e33d9fc97a661be30a4d8f9
37 lines
820 B
JavaScript
37 lines
820 B
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';
|
|
|
|
/**
|
|
* Sets up global variables for React Native.
|
|
* You can use this module directly, or just require InitializeCore.
|
|
*/
|
|
if (global.GLOBAL === undefined) {
|
|
global.GLOBAL = global;
|
|
}
|
|
|
|
if (global.window === undefined) {
|
|
// $FlowFixMe[cannot-write]
|
|
global.window = global;
|
|
}
|
|
|
|
if (global.self === undefined) {
|
|
// $FlowFixMe[cannot-write]
|
|
global.self = global;
|
|
}
|
|
|
|
// Set up process
|
|
global.process = global.process || {};
|
|
global.process.env = global.process.env || {};
|
|
if (!global.process.env.NODE_ENV) {
|
|
global.process.env.NODE_ENV = __DEV__ ? 'development' : 'production';
|
|
}
|