From fc68dfbed6154aa0a60a34c6d24c269561f60d99 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Wed, 12 Jul 2017 04:12:02 -0700 Subject: [PATCH] Enable flow for TouchableHighlight Reviewed By: fkgozali Differential Revision: D5388762 fbshipit-source-id: bec790a5e2ae5dbaf0f7bd2681ef156e870ed797 --- .../Touchable/TouchableHighlight.js | 39 +++++++++---------- .../Touchable/TouchableWithoutFeedback.js | 5 ++- Libraries/StyleSheet/EdgeInsetsPropType.js | 6 +-- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index a2281c6cd..19e601247 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -7,38 +7,36 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule TouchableHighlight - * @noflow + * @flow */ 'use strict'; -// Note (avik): add @flow when Flow supports spread properties in propTypes - -var ColorPropType = require('ColorPropType'); -var NativeMethodsMixin = require('NativeMethodsMixin'); +const ColorPropType = require('ColorPropType'); +const NativeMethodsMixin = require('NativeMethodsMixin'); const PropTypes = require('prop-types'); -var React = require('React'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var StyleSheet = require('StyleSheet'); -var TimerMixin = require('react-timer-mixin'); -var Touchable = require('Touchable'); -var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); -var View = require('View'); +const React = require('React'); +const ReactNativeViewAttributes = require('ReactNativeViewAttributes'); +const StyleSheet = require('StyleSheet'); +const TimerMixin = require('react-timer-mixin'); +const Touchable = require('Touchable'); +const TouchableWithoutFeedback = require('TouchableWithoutFeedback'); +const View = require('View'); const ViewPropTypes = require('ViewPropTypes'); -var createReactClass = require('create-react-class'); -var ensureComponentIsNative = require('ensureComponentIsNative'); -var ensurePositiveDelayProps = require('ensurePositiveDelayProps'); -var keyOf = require('fbjs/lib/keyOf'); -var merge = require('merge'); +const createReactClass = require('create-react-class'); +const ensureComponentIsNative = require('ensureComponentIsNative'); +const ensurePositiveDelayProps = require('ensurePositiveDelayProps'); +const keyOf = require('fbjs/lib/keyOf'); +const merge = require('merge'); -type Event = Object; +import type {Event} from 'TouchableWithoutFeedback'; -var DEFAULT_PROPS = { +const DEFAULT_PROPS = { activeOpacity: 0.85, underlayColor: 'black', }; -var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; +const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; /** * A wrapper for making views respond properly to touches. @@ -110,7 +108,6 @@ var TouchableHighlight = createReactClass({ * @platform ios */ tvParallaxProperties: PropTypes.object, - }, mixins: [NativeMethodsMixin, TimerMixin, Touchable.Mixin], diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index a36f0f141..60a41ec68 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -26,7 +26,7 @@ const { AccessibilityTraits, } = require('ViewAccessibility'); -type Event = Object; +export type Event = Object; const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; @@ -37,7 +37,6 @@ const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; * TouchableWithoutFeedback supports only one child. * If you wish to have several child components, wrap them in a View. */ -// $FlowFixMe(>=0.41.0) const TouchableWithoutFeedback = createReactClass({ displayName: 'TouchableWithoutFeedback', mixins: [TimerMixin, Touchable.Mixin], @@ -90,6 +89,7 @@ const TouchableWithoutFeedback = createReactClass({ * reactivated! Move it back and forth several times while the scroll view * is disabled. Ensure you pass in a constant to reduce memory allocations. */ + // $FlowFixMe: Expected a React PropType instead pressRetentionOffset: EdgeInsetsPropType, /** * This defines how far your touch can start away from the button. This is @@ -99,6 +99,7 @@ const TouchableWithoutFeedback = createReactClass({ * of sibling views always takes precedence if a touch hits two overlapping * views. */ + // $FlowFixMe: Expected a React PropType instead hitSlop: EdgeInsetsPropType, }, diff --git a/Libraries/StyleSheet/EdgeInsetsPropType.js b/Libraries/StyleSheet/EdgeInsetsPropType.js index 8faa0bfe5..66783fd85 100644 --- a/Libraries/StyleSheet/EdgeInsetsPropType.js +++ b/Libraries/StyleSheet/EdgeInsetsPropType.js @@ -11,11 +11,11 @@ */ 'use strict'; -var PropTypes = require('prop-types'); +const PropTypes = require('prop-types'); -var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); +const createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); -var EdgeInsetsPropType = createStrictShapeTypeChecker({ +const EdgeInsetsPropType = createStrictShapeTypeChecker({ top: PropTypes.number, left: PropTypes.number, bottom: PropTypes.number,