-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flow-strict] Flow TouchableNativeFeedback.android.js #22176
Conversation
Generated by 🚫 dangerJS |
I use |
@@ -13,6 +14,7 @@ const Platform = require('Platform'); | |||
const React = require('React'); | |||
const PropTypes = require('prop-types'); | |||
const ReactNative = require('ReactNative'); | |||
// $FlowFixMe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to fix the flow warning about not importing from untyped files, right? If that is the case then lets just not turn on strict-local in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviewing.
I applied flow to Touchable.js
then I removed FlowFixMe
from TouchableNativeFeedback.android.js
.
1996e49
to
4623d51
Compare
…o flow-touchable-native-feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍🏽
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RSNara has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mottox2: I noticed a few contradictions in this diff while I was reviewing it internally. You used LayoutEvent
in interesting ways. (I've fixed up the diff internally to only use PressEvent, so you don't need to push any updates to this). Before I landed the diff, I just wanted to check in here to see if I was missing something. 😅
@@ -652,12 +698,12 @@ const TouchableMixin = { | |||
); | |||
}, | |||
|
|||
_handleDelay: function(e) { | |||
_handleDelay: function(e: LayoutEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit curious. How come you decided to type this with LayoutEvent
?
this.touchableDelayTimeout = null; | ||
this._receiveSignal(Signals.DELAY, e); | ||
}, | ||
|
||
_handleLongDelay: function(e) { | ||
_handleLongDelay: function(e: LayoutEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same deal here. Why is this a LayoutEvent
and not a PressEvent
? This function calls _receiveSignal
, which I think should accept a PressEvent
.
return ( | ||
state === States.RESPONDER_ACTIVE_PRESS_IN || | ||
state === States.RESPONDER_ACTIVE_LONG_PRESS_IN | ||
); | ||
}, | ||
|
||
_savePressInLocation: function(e) { | ||
_savePressInLocation: function(e: LayoutEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on in the function, we call TouchEventUtils.extractSingleTouch
, which expects to be called with the native event of a PressEvent
. So, I think this type should be PressEvent
and not LayoutEvent
.
this._savePressInLocation(e); | ||
this.touchableHandleActivePressIn && this.touchableHandleActivePressIn(e); | ||
}, | ||
|
||
_endHighlight: function(e) { | ||
_endHighlight: function(e: LayoutEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method calls this.touchableHandleActivePressOut
, which you typed as accepting a PressEvent
inside TouchableNativeFeedback.android.js
. So, shouldn't the type of e
also be PressEvent
?
@@ -813,12 +869,12 @@ const TouchableMixin = { | |||
UIManager.playTouchSound(); | |||
}, | |||
|
|||
_startHighlight: function(e) { | |||
_startHighlight: function(e: LayoutEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same deal as _endHighlight
here.
nextState: State, | ||
signal: Signal, | ||
e: LayoutEvent, | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This event is forwarded to _startHighlight
and _endHighlight
. Shouldn't it therefore also be typed as a PressEvent
?
@@ -685,7 +731,7 @@ const TouchableMixin = { | |||
* @throws Error if invalid state transition or unrecognized signal. | |||
* @sideeffects | |||
*/ | |||
_receiveSignal: function(signal, e) { | |||
_receiveSignal: function(signal: Signal, e: LayoutEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets forwarded to _performSideEffectsForTransition
. So, shouldn't e
be typed as PressEvent
?
@@ -391,7 +430,7 @@ const TouchableMixin = { | |||
* @param {SyntheticEvent} e Synthetic event from event system. | |||
* | |||
*/ | |||
touchableHandleResponderGrant: function(e) { | |||
touchableHandleResponderGrant: function(e: SyntheticEvent<any>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function accepts a PressEvent.
this._receiveSignal(Signals.RESPONDER_RELEASE, e); | ||
}, | ||
|
||
/** | ||
* Place as callback for a DOM element's `onResponderTerminate` event. | ||
*/ | ||
touchableHandleResponderTerminate: function(e) { | ||
touchableHandleResponderTerminate: function(e: PressEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've typed this function as accepting a PressEvent
, but later on in the function, we forward this event to _receiveSignal
, which accepts a LayoutEvent. There's a contradiction here.
Summary: Related to facebook#22100 Turn Flow strict mode on for Libraries/Components/Touchable/TouchableNativeFeedback.android.js. Pull Request resolved: facebook#22176 Reviewed By: TheSavior Differential Revision: D13033239 Pulled By: RSNara fbshipit-source-id: 57e89ce16040e6238e01e0437327db943a5f2581
Related to #22100
Turn Flow strict mode on for Libraries/Components/Touchable/TouchableNativeFeedback.android.js.
Test Plan:
Changelog:
[GENERAL][FIXED] - apply flow