Skip to content

Commit 69213ee

Browse files
excedfacebook-github-bot
authored andcommitted
Flow strict TouchableOpacity (#22146)
Summary: Related to #22100 Enhance Flow types for TouchableOpacity specifying Touchable event types and TvParallaxPropertiesType. I had to export TvParallaxPropertiesType from TVViewPropTypes file. There are still 1 any left using requireNativeComponent and a dependency to `Touchable` that need to be addressed to turn Flow to strict mode. I guess `Touchable` is a lot more work since there's no flow annotation and it's still good old Mixin. - All flow tests succeed. [GENERAL] [ENHANCEMENT] [TouchableOpacity.js] - Flow types [GENERAL] [ENHANCEMENT] [TVViewPropTypes.js] - Export type Pull Request resolved: #22146 Reviewed By: TheSavior Differential Revision: D12927044 Pulled By: RSNara fbshipit-source-id: c63d805699dd58e2fbc4fd1df4ee0c9f87e2336a
1 parent c03fc40 commit 69213ee

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Libraries/Components/AppleTV/TVViewPropTypes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
'use strict';
1212

13-
type TVParallaxPropertiesType = $ReadOnly<{|
13+
export type TVParallaxPropertiesType = $ReadOnly<{|
1414
/**
1515
* If true, parallax effects are enabled. Defaults to true.
1616
*/

Libraries/Components/Touchable/TouchableOpacity.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ const flattenStyle = require('flattenStyle');
2424

2525
import type {Props as TouchableWithoutFeedbackProps} from 'TouchableWithoutFeedback';
2626
import type {ViewStyleProp} from 'StyleSheet';
27-
28-
type Event = Object;
27+
import type {TVParallaxPropertiesType} from 'TVViewPropTypes';
28+
import type {PressEvent} from 'CoreEventTypes';
2929

3030
const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
3131

3232
type TVProps = $ReadOnly<{|
3333
hasTVPreferredFocus?: ?boolean,
34-
tvParallaxProperties?: ?Object,
34+
tvParallaxProperties?: ?TVParallaxPropertiesType,
3535
|}>;
3636

3737
type Props = $ReadOnly<{|
@@ -193,7 +193,7 @@ const TouchableOpacity = ((createReactClass({
193193
* `Touchable.Mixin` self callbacks. The mixin will invoke these if they are
194194
* defined on your component.
195195
*/
196-
touchableHandleActivePressIn: function(e: Event) {
196+
touchableHandleActivePressIn: function(e: PressEvent) {
197197
if (e.dispatchConfig.registrationName === 'onResponderGrant') {
198198
this._opacityActive(0);
199199
} else {
@@ -202,16 +202,16 @@ const TouchableOpacity = ((createReactClass({
202202
this.props.onPressIn && this.props.onPressIn(e);
203203
},
204204

205-
touchableHandleActivePressOut: function(e: Event) {
205+
touchableHandleActivePressOut: function(e: PressEvent) {
206206
this._opacityInactive(250);
207207
this.props.onPressOut && this.props.onPressOut(e);
208208
},
209209

210-
touchableHandlePress: function(e: Event) {
210+
touchableHandlePress: function(e: PressEvent) {
211211
this.props.onPress && this.props.onPress(e);
212212
},
213213

214-
touchableHandleLongPress: function(e: Event) {
214+
touchableHandleLongPress: function(e: PressEvent) {
215215
this.props.onLongPress && this.props.onLongPress(e);
216216
},
217217

0 commit comments

Comments
 (0)