mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7f53bb95f7
Summary: The Flow team has been building a new implementation of the system that typechecks the body of generic functions and classes. This system is more sound than the previous approach and detects errors that were uncaught previously. This diff turns on the new generic system by setting generate_tests=false in the .flowconfig, and suppresses newly discovered errors. This diff modifies and re-signs some generated modules, because syncing from www pulled in a ton of other changes that have runtime differences, and I'm not equipped to verify that the changes are safe to land. Changelog: [Internal] Reviewed By: panagosg7 Differential Revision: D24801184 fbshipit-source-id: bb31fe4c5a4107d183649b436a548df5ff42e217
76 lines
1.7 KiB
JavaScript
76 lines
1.7 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.
|
|
*
|
|
* @format
|
|
* @flow strict
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import NativePlatformConstantsAndroid from './NativePlatformConstantsAndroid';
|
|
|
|
export type PlatformSelectSpec<A, N, D> = {
|
|
android?: A,
|
|
native?: N,
|
|
default?: D,
|
|
...
|
|
};
|
|
|
|
const Platform = {
|
|
__constants: null,
|
|
OS: 'android',
|
|
// $FlowFixMe[unsafe-getters-setters]
|
|
get Version(): number {
|
|
return this.constants.Version;
|
|
},
|
|
// $FlowFixMe[unsafe-getters-setters]
|
|
get constants(): {|
|
|
isTesting: boolean,
|
|
reactNativeVersion: {|
|
|
major: number,
|
|
minor: number,
|
|
patch: number,
|
|
prerelease: ?number,
|
|
|},
|
|
Version: number,
|
|
Release: string,
|
|
Serial: string,
|
|
Fingerprint: string,
|
|
Model: string,
|
|
ServerHost?: string,
|
|
uiMode: string,
|
|
Brand: string,
|
|
Manufacturer: string,
|
|
|} {
|
|
if (this.__constants == null) {
|
|
this.__constants = NativePlatformConstantsAndroid.getConstants();
|
|
}
|
|
return this.__constants;
|
|
},
|
|
// $FlowFixMe[unsafe-getters-setters]
|
|
get isTesting(): boolean {
|
|
if (__DEV__) {
|
|
return this.constants.isTesting;
|
|
}
|
|
return false;
|
|
},
|
|
// $FlowFixMe[unsafe-getters-setters]
|
|
get isTV(): boolean {
|
|
return this.constants.uiMode === 'tv';
|
|
},
|
|
select: <A, N, D>(spec: PlatformSelectSpec<A, N, D>): A | N | D =>
|
|
'android' in spec
|
|
? // $FlowFixMe[incompatible-return]
|
|
spec.android
|
|
: 'native' in spec
|
|
? // $FlowFixMe[incompatible-return]
|
|
spec.native
|
|
: // $FlowFixMe[incompatible-return]
|
|
spec.default,
|
|
};
|
|
|
|
module.exports = Platform;
|