Define type signature for react-native-implementation

Summary: Explicitly define the types of the getters in `react-native-implementation` so we can enable Flow's types-first mode for that file.

Reviewed By: cpojer

Differential Revision: D16937607

fbshipit-source-id: 2e4cf483043a53c5407254ffa2b3211d40211019
This commit is contained in:
Rubén Norte 2019-08-21 19:00:41 -07:00 коммит произвёл Facebook Github Bot
Родитель bc4825ee9d
Коммит d2213c75ff
4 изменённых файлов: 185 добавлений и 90 удалений

Просмотреть файл

@ -53,6 +53,9 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(si
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
experimental.well_formed_exports=true
experimental.well_formed_exports.whitelist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn

Просмотреть файл

@ -53,6 +53,9 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(si
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_android\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
experimental.well_formed_exports=true
experimental.well_formed_exports.whitelist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn

Просмотреть файл

@ -12,7 +12,6 @@ const Platform = require('../../Utilities/Platform');
const React = require('react');
const View = require('../View/View');
import type {NativeComponent} from '../../Renderer/shims/ReactNative';
import type {ViewProps} from '../View/ViewPropTypes';
type Props = $ReadOnly<{|
@ -20,7 +19,7 @@ type Props = $ReadOnly<{|
emulateUnlessSupported?: boolean,
|}>;
let exported: Class<React$Component<Props>> | Class<NativeComponent<Props>>;
let exported: Class<React$Component<Props>>;
/**
* Renders nested content and automatically applies paddings reflect the portion
@ -62,7 +61,7 @@ if (Platform.OS === 'android') {
const SafeAreaViewRef = React.forwardRef(SafeAreaView);
SafeAreaViewRef.displayName = 'SafeAreaView';
exported = ((SafeAreaViewRef: any): Class<NativeComponent<Props>>);
exported = ((SafeAreaViewRef: any): Class<React.Component<Props>>);
}
module.exports = exported;

Просмотреть файл

@ -10,19 +10,106 @@
'use strict';
import typeof AccessibilityInfo from '../Components/AccessibilityInfo/AccessibilityInfo';
import typeof ActivityIndicator from '../Components/ActivityIndicator/ActivityIndicator';
import typeof ReactNativeART from '../ART/ReactNativeART';
import typeof Button from '../Components/Button';
import typeof CheckBox from '../Components/CheckBox/CheckBox';
import typeof DatePickerIOS from '../Components/DatePicker/DatePickerIOS';
import typeof DrawerLayoutAndroid from '../Components/DrawerAndroid/DrawerLayoutAndroid';
import typeof FlatList from '../Lists/FlatList';
import typeof Image from '../Image/Image';
import typeof ImageBackground from '../Image/ImageBackground';
import typeof InputAccessoryView from '../Components/TextInput/InputAccessoryView';
import typeof KeyboardAvoidingView from '../Components/Keyboard/KeyboardAvoidingView';
import typeof MaskedViewIOS from '../Components/MaskedView/MaskedViewIOS';
import typeof Modal from '../Modal/Modal';
import typeof Picker from '../Components/Picker/Picker';
import typeof PickerIOS from '../Components/Picker/PickerIOS';
import typeof ProgressBarAndroid from '../Components/ProgressBarAndroid/ProgressBarAndroid';
import typeof ProgressViewIOS from '../Components/ProgressViewIOS/ProgressViewIOS';
import typeof SafeAreaView from '../Components/SafeAreaView/SafeAreaView';
import typeof ScrollView from '../Components/ScrollView/ScrollView';
import typeof SectionList from '../Lists/SectionList';
import typeof SegmentedControlIOS from '../Components/SegmentedControlIOS/SegmentedControlIOS';
import typeof Slider from '../Components/Slider/Slider';
import typeof Switch from '../Components/Switch/Switch';
import typeof RefreshControl from '../Components/RefreshControl/RefreshControl';
import typeof StatusBar from '../Components/StatusBar/StatusBar';
import typeof Text from '../Text/Text';
import typeof TextInput from '../Components/TextInput/TextInput';
import typeof Touchable from '../Components/Touchable/Touchable';
import typeof TouchableHighlight from '../Components/Touchable/TouchableHighlight';
import typeof TouchableNativeFeedback from '../Components/Touchable/TouchableNativeFeedback';
import typeof TouchableOpacity from '../Components/Touchable/TouchableOpacity';
import typeof TouchableWithoutFeedback from '../Components/Touchable/TouchableWithoutFeedback';
import typeof View from '../Components/View/View';
import typeof VirtualizedList from '../Lists/VirtualizedList';
import typeof VirtualizedSectionList from '../Lists/VirtualizedSectionList';
import typeof ActionSheetIOS from '../ActionSheetIOS/ActionSheetIOS';
import typeof Alert from '../Alert/Alert';
import typeof Animated from '../Animated/src/Animated';
import typeof AppRegistry from '../ReactNative/AppRegistry';
import typeof AppState from '../AppState/AppState';
import typeof AsyncStorage from '../Storage/AsyncStorage';
import typeof BackHandler from '../Utilities/BackHandler';
import typeof Clipboard from '../Components/Clipboard/Clipboard';
import typeof DatePickerAndroid from '../Components/DatePickerAndroid/DatePickerAndroid';
import typeof DeviceInfo from '../Utilities/DeviceInfo';
import typeof Dimensions from '../Utilities/Dimensions';
import typeof Easing from '../Animated/src/Easing';
import typeof ReactNative from '../Renderer/shims/ReactNative';
import typeof I18nManager from '../ReactNative/I18nManager';
import typeof ImagePickerIOS from '../Image/ImagePickerIOS';
import typeof InteractionManager from '../Interaction/InteractionManager';
import typeof Keyboard from '../Components/Keyboard/Keyboard';
import typeof LayoutAnimation from '../LayoutAnimation/LayoutAnimation';
import typeof Linking from '../Linking/Linking';
import typeof NativeDialogManagerAndroid from '../NativeModules/specs/NativeDialogManagerAndroid';
import typeof NativeEventEmitter from '../EventEmitter/NativeEventEmitter';
import typeof PanResponder from '../Interaction/PanResponder';
import typeof PermissionsAndroid from '../PermissionsAndroid/PermissionsAndroid';
import typeof PixelRatio from '../Utilities/PixelRatio';
import typeof PushNotificationIOS from '../PushNotificationIOS/PushNotificationIOS';
import typeof Settings from '../Settings/Settings';
import typeof Share from '../Share/Share';
import typeof StatusBarIOS from '../Components/StatusBar/StatusBarIOS';
import typeof StyleSheet from '../StyleSheet/StyleSheet';
import typeof Systrace from '../Performance/Systrace';
import typeof TimePickerAndroid from '../Components/TimePickerAndroid/TimePickerAndroid';
import typeof ToastAndroid from '../Components/ToastAndroid/ToastAndroid';
import typeof * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
import typeof TVEventHandler from '../Components/AppleTV/TVEventHandler';
import typeof UIManager from '../ReactNative/UIManager';
import typeof useWindowDimensions from '../Utilities/useWindowDimensions';
import typeof UTFSequence from '../UTFSequence';
import typeof Vibration from '../Vibration/Vibration';
import typeof YellowBox from '../YellowBox/YellowBox';
import typeof RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter';
import typeof RCTNativeAppEventEmitter from '../EventEmitter/RCTNativeAppEventEmitter';
import typeof NativeModules from '../BatchedBridge/NativeModules';
import typeof Platform from '../Utilities/Platform';
import typeof processColor from '../StyleSheet/processColor';
import typeof requireNativeComponent from '../ReactNative/requireNativeComponent';
import typeof RootTagContext from '../ReactNative/RootTagContext';
import typeof DeprecatedColorPropType from '../DeprecatedPropTypes/DeprecatedColorPropType';
import typeof DeprecatedEdgeInsetsPropType from '../DeprecatedPropTypes/DeprecatedEdgeInsetsPropType';
import typeof DeprecatedPointPropType from '../DeprecatedPropTypes/DeprecatedPointPropType';
import typeof DeprecatedViewPropTypes from '../DeprecatedPropTypes/DeprecatedViewPropTypes';
const invariant = require('invariant');
const warnOnce = require('../Utilities/warnOnce');
// Export React, plus some native additions.
module.exports = {
// Components
get AccessibilityInfo() {
get AccessibilityInfo(): AccessibilityInfo {
return require('../Components/AccessibilityInfo/AccessibilityInfo');
},
get ActivityIndicator() {
get ActivityIndicator(): ActivityIndicator {
return require('../Components/ActivityIndicator/ActivityIndicator');
},
get ART() {
get ART(): ReactNativeART {
warnOnce(
'art-moved',
'React Native ART has been extracted from react-native core and will be removed in a future release. ' +
@ -31,10 +118,10 @@ module.exports = {
);
return require('../ART/ReactNativeART');
},
get Button() {
get Button(): Button {
return require('../Components/Button');
},
get CheckBox() {
get CheckBox(): CheckBox {
warnOnce(
'checkBox-moved',
'CheckBox has been extracted from react-native core and will be removed in a future release. ' +
@ -43,7 +130,7 @@ module.exports = {
);
return require('../Components/CheckBox/CheckBox');
},
get DatePickerIOS() {
get DatePickerIOS(): DatePickerIOS {
warnOnce(
'DatePickerIOS-merged',
'DatePickerIOS has been merged with DatePickerAndroid and will be removed in a future release. ' +
@ -52,25 +139,25 @@ module.exports = {
);
return require('../Components/DatePicker/DatePickerIOS');
},
get DrawerLayoutAndroid() {
get DrawerLayoutAndroid(): DrawerLayoutAndroid {
return require('../Components/DrawerAndroid/DrawerLayoutAndroid');
},
get FlatList() {
get FlatList(): FlatList {
return require('../Lists/FlatList');
},
get Image() {
get Image(): Image {
return require('../Image/Image');
},
get ImageBackground() {
get ImageBackground(): ImageBackground {
return require('../Image/ImageBackground');
},
get InputAccessoryView() {
get InputAccessoryView(): InputAccessoryView {
return require('../Components/TextInput/InputAccessoryView');
},
get KeyboardAvoidingView() {
get KeyboardAvoidingView(): KeyboardAvoidingView {
return require('../Components/Keyboard/KeyboardAvoidingView');
},
get MaskedViewIOS() {
get MaskedViewIOS(): MaskedViewIOS {
warnOnce(
'maskedviewios-moved',
'MaskedViewIOS has been extracted from react-native core and will be removed in a future release. ' +
@ -79,34 +166,34 @@ module.exports = {
);
return require('../Components/MaskedView/MaskedViewIOS');
},
get Modal() {
get Modal(): Modal {
return require('../Modal/Modal');
},
get Picker() {
get Picker(): Picker {
return require('../Components/Picker/Picker');
},
get PickerIOS() {
get PickerIOS(): PickerIOS {
return require('../Components/Picker/PickerIOS');
},
get ProgressBarAndroid() {
get ProgressBarAndroid(): ProgressBarAndroid {
return require('../Components/ProgressBarAndroid/ProgressBarAndroid');
},
get ProgressViewIOS() {
get ProgressViewIOS(): ProgressViewIOS {
return require('../Components/ProgressViewIOS/ProgressViewIOS');
},
get SafeAreaView() {
get SafeAreaView(): SafeAreaView {
return require('../Components/SafeAreaView/SafeAreaView');
},
get ScrollView() {
get ScrollView(): ScrollView {
return require('../Components/ScrollView/ScrollView');
},
get SectionList() {
get SectionList(): SectionList {
return require('../Lists/SectionList');
},
get SegmentedControlIOS() {
get SegmentedControlIOS(): SegmentedControlIOS {
return require('../Components/SegmentedControlIOS/SegmentedControlIOS');
},
get Slider() {
get Slider(): Slider {
warnOnce(
'slider-moved',
'Slider has been extracted from react-native core and will be removed in a future release. ' +
@ -115,63 +202,63 @@ module.exports = {
);
return require('../Components/Slider/Slider');
},
get Switch() {
get Switch(): Switch {
return require('../Components/Switch/Switch');
},
get RefreshControl() {
get RefreshControl(): RefreshControl {
return require('../Components/RefreshControl/RefreshControl');
},
get StatusBar() {
get StatusBar(): StatusBar {
return require('../Components/StatusBar/StatusBar');
},
get Text() {
get Text(): Text {
return require('../Text/Text');
},
get TextInput() {
get TextInput(): TextInput {
return require('../Components/TextInput/TextInput');
},
get Touchable() {
get Touchable(): Touchable {
return require('../Components/Touchable/Touchable');
},
get TouchableHighlight() {
get TouchableHighlight(): TouchableHighlight {
return require('../Components/Touchable/TouchableHighlight');
},
get TouchableNativeFeedback() {
get TouchableNativeFeedback(): TouchableNativeFeedback {
return require('../Components/Touchable/TouchableNativeFeedback');
},
get TouchableOpacity() {
get TouchableOpacity(): TouchableOpacity {
return require('../Components/Touchable/TouchableOpacity');
},
get TouchableWithoutFeedback() {
get TouchableWithoutFeedback(): TouchableWithoutFeedback {
return require('../Components/Touchable/TouchableWithoutFeedback');
},
get View() {
get View(): View {
return require('../Components/View/View');
},
get VirtualizedList() {
get VirtualizedList(): VirtualizedList {
return require('../Lists/VirtualizedList');
},
get VirtualizedSectionList() {
get VirtualizedSectionList(): VirtualizedSectionList {
return require('../Lists/VirtualizedSectionList');
},
// APIs
get ActionSheetIOS() {
get ActionSheetIOS(): ActionSheetIOS {
return require('../ActionSheetIOS/ActionSheetIOS');
},
get Alert() {
get Alert(): Alert {
return require('../Alert/Alert');
},
get Animated() {
get Animated(): Animated {
return require('../Animated/src/Animated');
},
get AppRegistry() {
get AppRegistry(): AppRegistry {
return require('../ReactNative/AppRegistry');
},
get AppState() {
get AppState(): AppState {
return require('../AppState/AppState');
},
get AsyncStorage() {
get AsyncStorage(): AsyncStorage {
warnOnce(
'async-storage-moved',
'AsyncStorage has been extracted from react-native core and will be removed in a future release. ' +
@ -180,13 +267,13 @@ module.exports = {
);
return require('../Storage/AsyncStorage');
},
get BackHandler() {
get BackHandler(): BackHandler {
return require('../Utilities/BackHandler');
},
get Clipboard() {
get Clipboard(): Clipboard {
return require('../Components/Clipboard/Clipboard');
},
get DatePickerAndroid() {
get DatePickerAndroid(): DatePickerAndroid {
warnOnce(
'DatePickerAndroid-merged',
'DatePickerAndroid has been merged with DatePickerIOS and will be removed in a future release. ' +
@ -195,22 +282,22 @@ module.exports = {
);
return require('../Components/DatePickerAndroid/DatePickerAndroid');
},
get DeviceInfo() {
get DeviceInfo(): DeviceInfo {
return require('../Utilities/DeviceInfo');
},
get Dimensions() {
get Dimensions(): Dimensions {
return require('../Utilities/Dimensions');
},
get Easing() {
get Easing(): Easing {
return require('../Animated/src/Easing');
},
get findNodeHandle() {
get findNodeHandle(): $PropertyType<ReactNative, 'findNodeHandle'> {
return require('../Renderer/shims/ReactNative').findNodeHandle;
},
get I18nManager() {
get I18nManager(): I18nManager {
return require('../ReactNative/I18nManager');
},
get ImagePickerIOS() {
get ImagePickerIOS(): ImagePickerIOS {
warnOnce(
'imagePickerIOS-moved',
'ImagePickerIOS has been extracted from react-native core and will be removed in a future release. ' +
@ -220,34 +307,34 @@ module.exports = {
);
return require('../Image/ImagePickerIOS');
},
get InteractionManager() {
get InteractionManager(): InteractionManager {
return require('../Interaction/InteractionManager');
},
get Keyboard() {
get Keyboard(): Keyboard {
return require('../Components/Keyboard/Keyboard');
},
get LayoutAnimation() {
get LayoutAnimation(): LayoutAnimation {
return require('../LayoutAnimation/LayoutAnimation');
},
get Linking() {
get Linking(): Linking {
return require('../Linking/Linking');
},
get NativeDialogManagerAndroid() {
get NativeDialogManagerAndroid(): NativeDialogManagerAndroid {
return require('../NativeModules/specs/NativeDialogManagerAndroid').default;
},
get NativeEventEmitter() {
get NativeEventEmitter(): NativeEventEmitter {
return require('../EventEmitter/NativeEventEmitter');
},
get PanResponder() {
get PanResponder(): PanResponder {
return require('../Interaction/PanResponder');
},
get PermissionsAndroid() {
get PermissionsAndroid(): PermissionsAndroid {
return require('../PermissionsAndroid/PermissionsAndroid');
},
get PixelRatio() {
get PixelRatio(): PixelRatio {
return require('../Utilities/PixelRatio');
},
get PushNotificationIOS() {
get PushNotificationIOS(): PushNotificationIOS {
warnOnce(
'pushNotificationIOS-moved',
'PushNotificationIOS has been extracted from react-native core and will be removed in a future release. ' +
@ -256,26 +343,26 @@ module.exports = {
);
return require('../PushNotificationIOS/PushNotificationIOS');
},
get Settings() {
get Settings(): Settings {
return require('../Settings/Settings');
},
get Share() {
get Share(): Share {
return require('../Share/Share');
},
get StatusBarIOS() {
get StatusBarIOS(): StatusBarIOS {
warnOnce(
'StatusBarIOS-merged',
'StatusBarIOS has been merged with StatusBar and will be removed in a future release. Use StatusBar for mutating the status bar',
);
return require('../Components/StatusBar/StatusBarIOS');
},
get StyleSheet() {
get StyleSheet(): StyleSheet {
return require('../StyleSheet/StyleSheet');
},
get Systrace() {
get Systrace(): Systrace {
return require('../Performance/Systrace');
},
get TimePickerAndroid() {
get TimePickerAndroid(): TimePickerAndroid {
warnOnce(
'TimePickerAndroid-merged',
'TimePickerAndroid has been merged with DatePickerIOS and DatePickerAndroid and will be removed in a future release. ' +
@ -284,68 +371,71 @@ module.exports = {
);
return require('../Components/TimePickerAndroid/TimePickerAndroid');
},
get ToastAndroid() {
get ToastAndroid(): ToastAndroid {
return require('../Components/ToastAndroid/ToastAndroid');
},
get TurboModuleRegistry() {
get TurboModuleRegistry(): TurboModuleRegistry {
return require('../TurboModule/TurboModuleRegistry');
},
get TVEventHandler() {
get TVEventHandler(): TVEventHandler {
return require('../Components/AppleTV/TVEventHandler');
},
get UIManager() {
get UIManager(): UIManager {
return require('../ReactNative/UIManager');
},
get unstable_batchedUpdates() {
get unstable_batchedUpdates(): $PropertyType<
ReactNative,
'unstable_batchedUpdates',
> {
return require('../Renderer/shims/ReactNative').unstable_batchedUpdates;
},
get useWindowDimensions() {
get useWindowDimensions(): useWindowDimensions {
return require('../Utilities/useWindowDimensions').default;
},
get UTFSequence() {
get UTFSequence(): UTFSequence {
return require('../UTFSequence');
},
get Vibration() {
get Vibration(): Vibration {
return require('../Vibration/Vibration');
},
get YellowBox() {
get YellowBox(): YellowBox {
return require('../YellowBox/YellowBox');
},
// Plugins
get DeviceEventEmitter() {
get DeviceEventEmitter(): RCTDeviceEventEmitter {
return require('../EventEmitter/RCTDeviceEventEmitter');
},
get NativeAppEventEmitter() {
get NativeAppEventEmitter(): RCTNativeAppEventEmitter {
return require('../EventEmitter/RCTNativeAppEventEmitter');
},
get NativeModules() {
get NativeModules(): NativeModules {
return require('../BatchedBridge/NativeModules');
},
get Platform() {
get Platform(): Platform {
return require('../Utilities/Platform');
},
get processColor() {
get processColor(): processColor {
return require('../StyleSheet/processColor');
},
get requireNativeComponent() {
get requireNativeComponent(): requireNativeComponent {
return require('../ReactNative/requireNativeComponent');
},
get unstable_RootTagContext() {
get unstable_RootTagContext(): RootTagContext {
return require('../ReactNative/RootTagContext');
},
// Prop Types
get ColorPropType() {
get ColorPropType(): DeprecatedColorPropType {
return require('../DeprecatedPropTypes/DeprecatedColorPropType');
},
get EdgeInsetsPropType() {
get EdgeInsetsPropType(): DeprecatedEdgeInsetsPropType {
return require('../DeprecatedPropTypes/DeprecatedEdgeInsetsPropType');
},
get PointPropType() {
get PointPropType(): DeprecatedPointPropType {
return require('../DeprecatedPropTypes/DeprecatedPointPropType');
},
get ViewPropTypes() {
get ViewPropTypes(): DeprecatedViewPropTypes {
return require('../DeprecatedPropTypes/DeprecatedViewPropTypes');
},
};