Skip to content

Commit

Permalink
Flow strict TouchableOpacity (facebook#22146)
Browse files Browse the repository at this point in the history
Summary:
Related to facebook#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: facebook#22146

Reviewed By: TheSavior

Differential Revision: D12927044

Pulled By: RSNara

fbshipit-source-id: c63d805699dd58e2fbc4fd1df4ee0c9f87e2336a
  • Loading branch information
exced authored and facebook-github-bot committed Nov 6, 2018
1 parent a2844f2 commit bb7428e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Libraries/Components/AppleTV/TVViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

type TVParallaxPropertiesType = $ReadOnly<{|
export type TVParallaxPropertiesType = $ReadOnly<{|
/**
* If true, parallax effects are enabled. Defaults to true.
*/
Expand Down
14 changes: 7 additions & 7 deletions Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ const flattenStyle = require('flattenStyle');

import type {Props as TouchableWithoutFeedbackProps} from 'TouchableWithoutFeedback';
import type {ViewStyleProp} from 'StyleSheet';

type Event = Object;
import type {TVParallaxPropertiesType} from 'TVViewPropTypes';
import type {PressEvent} from 'CoreEventTypes';

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

type TVProps = $ReadOnly<{|
hasTVPreferredFocus?: ?boolean,
tvParallaxProperties?: ?Object,
tvParallaxProperties?: ?TVParallaxPropertiesType,
|}>;

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

touchableHandleActivePressOut: function(e: Event) {
touchableHandleActivePressOut: function(e: PressEvent) {
this._opacityInactive(250);
this.props.onPressOut && this.props.onPressOut(e);
},

touchableHandlePress: function(e: Event) {
touchableHandlePress: function(e: PressEvent) {
this.props.onPress && this.props.onPress(e);
},

touchableHandleLongPress: function(e: Event) {
touchableHandleLongPress: function(e: PressEvent) {
this.props.onLongPress && this.props.onLongPress(e);
},

Expand Down

0 comments on commit bb7428e

Please sign in to comment.