From f125815efc5c33bbe71ddc7395bf650a154b909e Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 13 Aug 2018 11:14:35 -0700 Subject: [PATCH] Add flow suppressions to xplat android Summary: .android.js files may be checked (when the next version of flow is released) by using `flow start --flowconfig-name .flowconfig.android` and `flow status --flowconfig-name .flowconfig.android` This diff adds suppressions to the errors that are in .android.js files, which flow does not check right now. When site is `react_native_fb` or `react_native_android_fb`, error will be suppressed when checking with .flowconfig.android When site is `react_native_fb` or `react_native_ios_fb`, error will be suppressed when checking with .flowconfig. You can use `react_native_fb` when it should be suppressed for both. The controller you requested could not be found. Reviewed By: TheSavior Differential Revision: D9122178 fbshipit-source-id: 0ec9d3cae3d887f58645e6585b2a3f6c3889b13e --- .../AccessibilityInfo.android.js | 2 + .../ActivityIndicator/ActivityIndicator.js | 2 + .../Components/CheckBox/CheckBox.android.js | 4 ++ .../Picker/PickerAndroid.android.js | 22 +++++++++++ .../StatusBar/StatusBarIOS.android.js | 2 + .../ViewPager/ViewPagerAndroid.android.js | 10 +++++ Libraries/Image/Image.android.js | 6 +++ Libraries/Network/XMLHttpRequest.js | 2 + .../js/ProgressBarAndroidExample.android.js | 4 ++ RNTester/js/RNTesterApp.android.js | 30 +++++++++++++++ RNTester/js/RNTesterExampleList.js | 2 + RNTester/js/RNTesterList.android.js | 16 ++++++++ RNTester/js/TextInputExample.android.js | 38 +++++++++++++++++++ 13 files changed, 140 insertions(+) diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js index 09547ea06..f3bb359b7 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js @@ -35,6 +35,8 @@ const _subscriptions = new Map(); */ const AccessibilityInfo = { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ fetch: function(): Promise { return new Promise((resolve, reject) => { RCTAccessibilityInfo.isTouchExplorationEnabled(function(resp) { diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/Libraries/Components/ActivityIndicator/ActivityIndicator.js index abe6a75af..1969b59d4 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -103,6 +103,8 @@ const ActivityIndicator = ( styles.container, style, )}> + {/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */} ); diff --git a/Libraries/Components/CheckBox/CheckBox.android.js b/Libraries/Components/CheckBox/CheckBox.android.js index 0c7f13dec..45a3e6f08 100644 --- a/Libraries/Components/CheckBox/CheckBox.android.js +++ b/Libraries/Components/CheckBox/CheckBox.android.js @@ -131,7 +131,11 @@ let CheckBox = createReactClass({ let props = {...this.props}; props.onStartShouldSetResponder = () => true; props.onResponderTerminationRequest = () => false; + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ props.enabled = !this.props.disabled; + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ props.on = this.props.value; props.style = [styles.rctCheckBox, this.props.style]; diff --git a/Libraries/Components/Picker/PickerAndroid.android.js b/Libraries/Components/Picker/PickerAndroid.android.js index 1f80aa392..7066b942a 100644 --- a/Libraries/Components/Picker/PickerAndroid.android.js +++ b/Libraries/Components/Picker/PickerAndroid.android.js @@ -49,6 +49,8 @@ class PickerAndroid extends React.Component< }, *, > { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ static propTypes = { ...ViewPropTypes, style: pickerStyleType, @@ -60,6 +62,8 @@ class PickerAndroid extends React.Component< testID: ReactPropTypes.string, }; + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ constructor(props, context) { super(props, context); const state = this._stateFromProps(props); @@ -70,6 +74,8 @@ class PickerAndroid extends React.Component< }; } + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ UNSAFE_componentWillReceiveProps(nextProps) { this.setState(this._stateFromProps(nextProps)); } @@ -86,6 +92,8 @@ class PickerAndroid extends React.Component< label: child.props.label, }; if (child.props.color) { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ childProps.color = processColor(child.props.color); } return childProps; @@ -106,6 +114,8 @@ class PickerAndroid extends React.Component< selected: this.state.initialSelectedIndex, testID: this.props.testID, style: [styles.pickerAndroid, this.props.style], + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ accessibilityLabel: this.props.accessibilityLabel, }; @@ -116,18 +126,26 @@ class PickerAndroid extends React.Component< if (this.props.onValueChange) { const position = event.nativeEvent.position; if (position >= 0) { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ const children = React.Children.toArray(this.props.children); const value = children[position].props.value; + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ this.props.onValueChange(value, position); } else { this.props.onValueChange(null, position); } } + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this._lastNativePosition = event.nativeEvent.position; this.forceUpdate(); }; componentDidMount() { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this._lastNativePosition = this.state.initialSelectedIndex; } @@ -140,11 +158,15 @@ class PickerAndroid extends React.Component< // truth, not the native component. if ( this.refs[REF_PICKER] && + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this.state.selectedIndex !== this._lastNativePosition ) { this.refs[REF_PICKER].setNativeProps({ selected: this.state.selectedIndex, }); + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this._lastNativePosition = this.state.selectedIndex; } } diff --git a/Libraries/Components/StatusBar/StatusBarIOS.android.js b/Libraries/Components/StatusBar/StatusBarIOS.android.js index 96f77d786..78831fab6 100644 --- a/Libraries/Components/StatusBar/StatusBarIOS.android.js +++ b/Libraries/Components/StatusBar/StatusBarIOS.android.js @@ -12,4 +12,6 @@ const NativeEventEmitter = require('NativeEventEmitter'); +/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found when + * making Flow check .android.js files. */ module.exports = new NativeEventEmitter('StatusBarManager'); diff --git a/Libraries/Components/ViewPager/ViewPagerAndroid.android.js b/Libraries/Components/ViewPager/ViewPagerAndroid.android.js index 2ccdd31b5..2b69a2777 100644 --- a/Libraries/Components/ViewPager/ViewPagerAndroid.android.js +++ b/Libraries/Components/ViewPager/ViewPagerAndroid.android.js @@ -82,6 +82,8 @@ class ViewPagerAndroid extends React.Component<{ keyboardDismissMode?: 'none' | 'on-drag', scrollEnabled?: boolean, }> { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ static propTypes = { ...ViewPropTypes, /** @@ -154,14 +156,20 @@ class ViewPagerAndroid extends React.Component<{ } } + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ getInnerViewNode = (): ReactComponent => { return this.refs[VIEWPAGER_REF].getInnerViewNode(); }; + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ _childrenWithOverridenStyle = (): Array => { // Override styles so that each page will fill the parent. Native component // will handle positioning of elements, so it's not important to offset // them correctly. + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ return React.Children.map(this.props.children, function(child) { if (!child) { return null; @@ -247,6 +255,8 @@ class ViewPagerAndroid extends React.Component<{ =0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ style={this.props.style} onPageScroll={this._onPageScroll} onPageScrollStateChanged={this._onPageScrollStateChanged} diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index c8cedddab..0058b210d 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -219,8 +219,12 @@ let Image = ( let style; let sources; if (source?.uri != null) { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ const {width, height} = source; style = flattenStyle([{width, height}, styles.base, props.style]); + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ sources = [{uri: source.uri}]; } else { style = flattenStyle([styles.base, props.style]); @@ -232,6 +236,8 @@ let Image = ( style, shouldNotifyLoadEvents: !!(onLoadStart || onLoad || onLoadEnd || onError), src: sources, + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ headers: source?.headers, defaultSrc: defaultSource ? defaultSource.uri : null, loadingIndicatorSrc: loadingIndicatorSource diff --git a/Libraries/Network/XMLHttpRequest.js b/Libraries/Network/XMLHttpRequest.js index e8be40a0a..273b07144 100644 --- a/Libraries/Network/XMLHttpRequest.js +++ b/Libraries/Network/XMLHttpRequest.js @@ -522,6 +522,8 @@ class XMLHttpRequest extends EventTarget(...XHR_EVENTS) { this._url, this._headers, data, + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ nativeResponseType, incrementalEvents, this.timeout, diff --git a/RNTester/js/ProgressBarAndroidExample.android.js b/RNTester/js/ProgressBarAndroidExample.android.js index 2b3d7feea..17da936b2 100644 --- a/RNTester/js/ProgressBarAndroidExample.android.js +++ b/RNTester/js/ProgressBarAndroidExample.android.js @@ -48,6 +48,8 @@ class ProgressBarAndroidExample extends React.Component<{}> { return ( + {/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */} @@ -56,6 +58,8 @@ class ProgressBarAndroidExample extends React.Component<{}> { + {/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */} diff --git a/RNTester/js/RNTesterApp.android.js b/RNTester/js/RNTesterApp.android.js index 42c43b81a..61f226029 100644 --- a/RNTester/js/RNTesterApp.android.js +++ b/RNTester/js/RNTesterApp.android.js @@ -23,6 +23,8 @@ const ToolbarAndroid = require('ToolbarAndroid'); const RNTesterActions = require('./RNTesterActions'); const RNTesterExampleContainer = require('./RNTesterExampleContainer'); const RNTesterExampleList = require('./RNTesterExampleList'); +/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found when + * making Flow check .android.js files. */ const RNTesterList = require('./RNTesterList'); const RNTesterNavigationReducer = require('./RNTesterNavigationReducer'); const UIManager = require('UIManager'); @@ -96,12 +98,18 @@ class RNTesterApp extends React.Component { drawerWidth={Dimensions.get('window').width - DRAWER_WIDTH_LEFT} keyboardDismissMode="on-drag" onDrawerOpen={() => { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ this._overrideBackPressForDrawerLayout = true; }} onDrawerClose={() => { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ this._overrideBackPressForDrawerLayout = false; }} ref={drawer => { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ this.drawer = drawer; }} renderNavigationView={this._renderDrawerContent} @@ -114,6 +122,8 @@ class RNTesterApp extends React.Component { _renderDrawerContent = () => { return ( + {/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */} { this._handleAction(RNTesterActions.Back()); }} ref={example => { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue + * was found when making Flow check .android.js files. */ this._exampleRef = example; }} /> @@ -146,6 +158,8 @@ class RNTesterApp extends React.Component { =0.78.0 site=react_native_android_fb) This issue + * was found when making Flow check .android.js files. */ onIconClicked={() => this.drawer.openDrawer()} style={styles.toolbar} title={ExampleModule.title} @@ -153,6 +167,8 @@ class RNTesterApp extends React.Component { { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue + * was found when making Flow check .android.js files. */ this._exampleRef = example; }} /> @@ -166,10 +182,14 @@ class RNTesterApp extends React.Component { =0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ onIconClicked={() => this.drawer.openDrawer()} style={styles.toolbar} title="RNTester" /> + {/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */} { } _handleAction = (action: Object): boolean => { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this.drawer && this.drawer.closeDrawer(); const newState = RNTesterNavigationReducer(this.state, action); if (this.state !== newState) { @@ -191,16 +213,24 @@ class RNTesterApp extends React.Component { }; _handleBackButtonPress = () => { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ if (this._overrideBackPressForDrawerLayout) { // This hack is necessary because drawer layout provides an imperative API // with open and close methods. This code would be cleaner if the drawer // layout provided an `isOpen` prop and allowed us to pass a `onDrawerClose` handler. + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this.drawer && this.drawer.closeDrawer(); return true; } if ( + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this._exampleRef && this._exampleRef.handleBackAction && + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this._exampleRef.handleBackAction() ) { return true; diff --git a/RNTester/js/RNTesterExampleList.js b/RNTester/js/RNTesterExampleList.js index 325a5bce8..7ad207a80 100644 --- a/RNTester/js/RNTesterExampleList.js +++ b/RNTester/js/RNTesterExampleList.js @@ -21,6 +21,8 @@ const RNTesterActions = require('./RNTesterActions'); const RNTesterStatePersister = require('./RNTesterStatePersister'); const View = require('View'); +/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found when + * making Flow check .android.js files. */ import type {RNTesterExample} from './RNTesterList.ios'; import type {PassProps} from './RNTesterStatePersister'; import type {DangerouslyImpreciseStyleProp} from 'StyleSheet'; diff --git a/RNTester/js/RNTesterList.android.js b/RNTester/js/RNTesterList.android.js index 8e8f6b791..82906abc0 100644 --- a/RNTester/js/RNTesterList.android.js +++ b/RNTester/js/RNTesterList.android.js @@ -62,6 +62,8 @@ const ComponentExamples: Array = [ }, { key: 'ProgressBarAndroidExample', + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ module: require('./ProgressBarAndroidExample'), }, { @@ -98,14 +100,20 @@ const ComponentExamples: Array = [ }, { key: 'TextExample', + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ module: require('./TextExample'), }, { key: 'TextInputExample', + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ module: require('./TextInputExample'), }, { key: 'ToolbarAndroidExample', + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ module: require('./ToolbarAndroidExample'), }, { @@ -118,6 +126,8 @@ const ComponentExamples: Array = [ }, { key: 'ViewPagerAndroidExample', + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ module: require('./ViewPagerAndroidExample'), }, { @@ -129,6 +139,8 @@ const ComponentExamples: Array = [ const APIExamples: Array = [ { key: 'AccessibilityAndroidExample', + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ module: require('./AccessibilityAndroidExample'), }, { @@ -205,6 +217,8 @@ const APIExamples: Array = [ }, { key: 'PermissionsExampleAndroid', + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ module: require('./PermissionsExampleAndroid'), }, { @@ -229,6 +243,8 @@ const APIExamples: Array = [ }, { key: 'ToastAndroidExample', + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ module: require('./ToastAndroidExample'), }, { diff --git a/RNTester/js/TextInputExample.android.js b/RNTester/js/TextInputExample.android.js index 30cee2eb2..5fba895bf 100644 --- a/RNTester/js/TextInputExample.android.js +++ b/RNTester/js/TextInputExample.android.js @@ -84,6 +84,8 @@ class RewriteExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> { var remainder = limit - this.state.text.length; var remainderColor = remainder > 5 ? 'blue' : 'red'; return ( + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ { text = text.replace(/ /g, '_'); this.setState({text}); }} + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ style={styles.default} value={this.state.text} /> + {/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */} {remainder} @@ -299,6 +305,8 @@ class SelectionExample extends React.Component< onChangeText={value => this.setState({value})} onSelectionChange={this.onSelectionChange.bind(this)} ref={textInput => (this._textInput = textInput)} + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ selection={this.state.selection} style={this.props.style} value={this.state.value} @@ -324,6 +332,8 @@ class AutogrowingTextInputExample extends React.Component<{}> { constructor(props) { super(props); + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this.state = { width: 100, multiline: true, @@ -336,12 +346,18 @@ class AutogrowingTextInputExample extends React.Component<{}> { } UNSAFE_componentWillReceiveProps(props) { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ this.setState({ + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ multiline: props.multiline, }); } render() { + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found + * when making Flow check .android.js files. */ var {style, multiline, ...props} = this.props; return ( @@ -351,25 +367,43 @@ class AutogrowingTextInputExample extends React.Component<{}> { minimumValue={0} maximumValue={100} step={10} + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ onValueChange={value => this.setState({width: value})} /> Multiline: =0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ value={this.state.multiline} + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ onValueChange={value => this.setState({multiline: value})} /> TextInput: =0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ multiline={this.state.multiline} + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ style={[style, {width: this.state.width + '%'}]} + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ onChangeText={value => this.setState({text: value})} onContentSizeChange={event => + /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ this.setState({contentSize: event.nativeEvent.contentSize}) } {...props} /> Plain text value representation: + {/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */} {this.state.text} + {/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */} Content Size: {JSON.stringify(this.state.contentSize)} ); @@ -407,6 +441,8 @@ exports.examples = [ =0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ style={styles.input} accessibilityLabel="I am the accessibility label for text input" /> @@ -801,6 +837,8 @@ exports.examples = [ return ( =0.78.0 site=react_native_android_fb) This issue was + * found when making Flow check .android.js files. */ style={styles.default} value="text selection can be changed" />