From 0b79d1faa21eb3c29aeeba08ee0fb2ed62e6cc54 Mon Sep 17 00:00:00 2001 From: Eli White Date: Sat, 12 May 2018 23:10:42 -0700 Subject: [PATCH] Type TouchableWithoutFeedback Reviewed By: yungsters Differential Revision: D7982348 fbshipit-source-id: 409ce4a5ea8c09e58c42caf9db60117253503c4c --- .../Touchable/TouchableWithoutFeedback.js | 43 ++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index 8594846b3de9f6..f80fd9a07cd774 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -32,9 +32,41 @@ const { } = require('ViewAccessibility'); import type {PressEvent} from 'CoreEventTypes'; +import type {EdgeInsetsProp} from 'EdgeInsetsPropType'; +import type { + AccessibilityComponentType, + AccessibilityTrait, +} from 'ViewAccessibility'; const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; +type Props = $ReadOnly<{| + accessible?: boolean, + accessibilityComponentType?: AccessibilityComponentType, + accessibilityLabel?: + | null + | React$PropType$Primitive + | string + | Array + | any, + accessibilityTraits?: AccessibilityTrait | Array, + children?: ?React.Node, + delayLongPress?: ?number, + delayPressIn?: ?number, + delayPressOut?: ?number, + disabled?: ?boolean, + hitSlop?: ?EdgeInsetsProp, + nativeID?: ?string, + onLayout?: ?Function, + onLongPress?: ?Function, + onPress?: ?Function, + onPressIn?: ?Function, + onPressOut?: ?Function, + pressRetentionOffset?: ?EdgeInsetsProp, + rejectResponderTermination?: ?boolean, + testID?: ?string, +|}>; + /** * Do not use unless you have a very good reason. All elements that * respond to press should have a visual feedback when touched. @@ -42,12 +74,13 @@ 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. */ -const TouchableWithoutFeedback = createReactClass({ +const TouchableWithoutFeedback = ((createReactClass({ displayName: 'TouchableWithoutFeedback', mixins: [TimerMixin, Touchable.Mixin], propTypes: { accessible: PropTypes.bool, + accessibilityLabel: PropTypes.node, accessibilityComponentType: PropTypes.oneOf(AccessibilityComponentTypes), accessibilityTraits: PropTypes.oneOfType([ PropTypes.oneOf(AccessibilityTraits), @@ -80,6 +113,9 @@ const TouchableWithoutFeedback = createReactClass({ onLongPress: PropTypes.func, + nativeID: PropTypes.string, + testID: PropTypes.string, + /** * Delay in ms, from the start of the touch, before onPressIn is called. */ @@ -195,13 +231,10 @@ const TouchableWithoutFeedback = createReactClass({ : child.props.style; return (React: any).cloneElement(child, { accessible: this.props.accessible !== false, - // $FlowFixMe Invalid prop usage accessibilityLabel: this.props.accessibilityLabel, accessibilityComponentType: this.props.accessibilityComponentType, accessibilityTraits: this.props.accessibilityTraits, - // $FlowFixMe Invalid prop usage nativeID: this.props.nativeID, - // $FlowFixMe Invalid prop usage testID: this.props.testID, onLayout: this.props.onLayout, hitSlop: this.props.hitSlop, @@ -216,6 +249,6 @@ const TouchableWithoutFeedback = createReactClass({ children, }); }, -}); +}): any): React.ComponentType); module.exports = TouchableWithoutFeedback;