[Flow] Fix or suppress react-native github errors for Flow v0.12.0

This commit is contained in:
Gabe Levi 2015-06-10 13:42:41 -07:00
parent 5d154f1af4
commit b05e99a531
12 changed files with 37 additions and 22 deletions

View File

@ -34,11 +34,14 @@ var MovieCell = React.createClass({
var criticsScore = this.props.movie.ratings.critics_score;
return (
<View>
<TouchableHighlight
<TouchableHighlight
onPress={this.props.onSelect}
onShowUnderlay={this.props.onHighlight}
onHideUnderlay={this.props.onUnhighlight}>
<View style={styles.row}>
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */}
<Image
source={getImageSource(this.props.movie, 'det')}
style={styles.cellImage}

View File

@ -34,6 +34,9 @@ var MovieScreen = React.createClass({
return (
<ScrollView contentContainerStyle={styles.contentContainer}>
<View style={styles.mainSection}>
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */}
<Image
source={getImageSource(this.props.movie, 'det')}
style={styles.detailsImage}

View File

@ -28,6 +28,9 @@ var SearchScreen = require('./SearchScreen');
var MoviesApp = React.createClass({
render: function() {
return (
/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */
<NavigatorIOS
style={styles.container}
initialRoute={{

View File

@ -159,12 +159,15 @@ var MapViewExample = React.createClass({
render() {
return (
<View>
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */}
<MapView
style={styles.map}
onRegionChange={this._onRegionChange}
onRegionChangeComplete={this._onRegionChangeComplete}
region={this.state.mapRegion}
annotations={this.state.annotations}
region={this.state.mapRegion || undefined}
annotations={this.state.annotations || undefined}
/>
<MapRegionInput
onChange={this._onRegionInputChanged}

View File

@ -44,6 +44,9 @@ var UIExplorerApp = React.createClass({
);
}
return (
/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */
<NavigatorIOS
style={styles.container}
initialRoute={{

View File

@ -37,9 +37,9 @@ var UIExplorerPage = React.createClass({
var ContentWrapper;
var wrapperProps = {};
if (this.props.noScroll) {
ContentWrapper = View;
ContentWrapper = (View: ReactClass<any, any, any>);
} else {
ContentWrapper = ScrollView;
ContentWrapper = (ScrollView: ReactClass<any, any, any>);
wrapperProps.keyboardShouldPersistTaps = true;
wrapperProps.keyboardDismissMode = 'interactive';
}

View File

@ -299,7 +299,7 @@ var ScrollView = React.createClass({
onResponderRelease: this.scrollResponderHandleResponderRelease,
onResponderReject: this.scrollResponderHandleResponderReject,
};
var ScrollViewClass;
if (Platform.OS === 'ios') {
ScrollViewClass = RCTScrollView;

View File

@ -147,7 +147,7 @@ var NetInfo = {
eventName: ChangeEventName,
handler: Function
): void {
_subscriptions[handler] = RCTDeviceEventEmitter.addListener(
_subscriptions[String(handler)] = RCTDeviceEventEmitter.addListener(
DEVICE_REACHABILITY_EVENT,
(appStateData) => {
handler(appStateData.network_reachability);
@ -159,11 +159,11 @@ var NetInfo = {
eventName: ChangeEventName,
handler: Function
): void {
if (!_subscriptions[handler]) {
if (!_subscriptions[String(handler)]) {
return;
}
_subscriptions[handler].remove();
_subscriptions[handler] = null;
_subscriptions[String(handler)].remove();
_subscriptions[String(handler)] = null;
},
fetch: function(): Promise {
@ -204,12 +204,12 @@ NetInfo.isConnected = {
eventName: ChangeEventName,
handler: Function
): void {
_isConnectedSubscriptions[handler] = (connection) => {
_isConnectedSubscriptions[String(handler)] = (connection) => {
handler(_isConnected(connection));
};
NetInfo.addEventListener(
eventName,
_isConnectedSubscriptions[handler]
_isConnectedSubscriptions[String(handler)]
);
},
@ -219,7 +219,7 @@ NetInfo.isConnected = {
): void {
NetInfo.removeEventListener(
eventName,
_isConnectedSubscriptions[handler]
_isConnectedSubscriptions[String(handler)]
);
},

View File

@ -66,14 +66,14 @@ class PushNotificationIOS {
'PushNotificationIOS only supports `notification` and `register` events'
);
if (type === 'notification') {
_notifHandlers[handler] = RCTDeviceEventEmitter.addListener(
_notifHandlers[String(handler)] = RCTDeviceEventEmitter.addListener(
DEVICE_NOTIF_EVENT,
(notifData) => {
handler(new PushNotificationIOS(notifData));
}
);
} else if (type === 'register') {
_notifHandlers[handler] = RCTDeviceEventEmitter.addListener(
_notifHandlers[String(handler)] = RCTDeviceEventEmitter.addListener(
NOTIF_REGISTER_EVENT,
(registrationInfo) => {
handler(registrationInfo.deviceToken);
@ -143,11 +143,11 @@ class PushNotificationIOS {
type === 'notification' || type === 'register',
'PushNotificationIOS only supports `notification` and `register` events'
);
if (!_notifHandlers[handler]) {
if (!_notifHandlers[String(handler)]) {
return;
}
_notifHandlers[handler].remove();
_notifHandlers[handler] = null;
_notifHandlers[String(handler)].remove();
_notifHandlers[String(handler)] = null;
}

View File

@ -20,7 +20,7 @@
*
* If none are set, returns false.
*/
function resolveBoxStyle(prefix: String, style: Object): ?Object {
function resolveBoxStyle(prefix: string, style: Object): ?Object {
var res = {};
var subs = ['top', 'left', 'bottom', 'right'];
var set = false;

View File

@ -26,7 +26,7 @@ type ReactNativeBaseComponentViewConfig = {
*/
var createReactNativeComponentClass = function(
viewConfig: ReactNativeBaseComponentViewConfig
): Function { // returning Function is lossy :/
): ReactClass<any, any, any> {
var Constructor = function(element) {
this._currentElement = element;
@ -39,7 +39,7 @@ var createReactNativeComponentClass = function(
Constructor.prototype = new ReactNativeBaseComponent(viewConfig);
Constructor.prototype.constructor = Constructor;
return Constructor;
return ((Constructor: any): ReactClass);
};
module.exports = createReactNativeComponentClass;

View File

@ -14,7 +14,7 @@
var GLOBAL = GLOBAL || this;
var BridgeProfiling = {
profile(profileName: String, args?: any) {
profile(profileName: string, args?: any) {
if (GLOBAL.__BridgeProfilingIsProfiling) {
if (args) {
try {