Skip to content

[flow-strict] Flow TouchableNativeFeedback.android.js - #22176

Closed
mottox2 wants to merge 9 commits into
react:masterfrom
mottox2:flow-touchable-native-feedback
Closed

mottox2 wants to merge 9 commits into
react:masterfrom
mottox2:flow-touchable-native-feedback

Conversation

@mottox2

@mottox2 mottox2 commented Nov 6, 2018 •

Copy link
Copy Markdown
Contributor

Related to #22100

Turn Flow strict mode on for Libraries/Components/Touchable/TouchableNativeFeedback.android.js.

Test Plan:

  • npm run prettier
  • npm run flow
  • npm run flow-check-ios
  • npm run flow-check-android
  • npm run lint
  • npm run test

Changelog:

[GENERAL][FIXED] - apply flow

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 6, 2018
@pull-bot

pull-bot commented Nov 6, 2018

Copy link
Copy Markdown
Warnings
⚠️

📋 Release Notes - This PR appears to be missing Release Notes.

Generated by 🚫 dangerJS

@mottox2 mottox2 changed the title [flow] Flow TouchableNativeFeedback.android.js [WIP] [flow] Flow TouchableNativeFeedback.android.js Nov 6, 2018
@mottox2

mottox2 commented Nov 6, 2018 •

Copy link
Copy Markdown
Contributor Author

Sorry. I will submit PR to apply flow strict to Touchable.js before this PR.

I use //$FlowFixMe to import Touchable.js.

@mottox2 mottox2 changed the title [WIP] [flow] Flow TouchableNativeFeedback.android.js [flow] Flow TouchableNativeFeedback.android.js Nov 6, 2018
@mottox2 mottox2 changed the title [flow] Flow TouchableNativeFeedback.android.js [flow-strict] Flow TouchableNativeFeedback.android.js Nov 6, 2018
const React = require('React');
const PropTypes = require('prop-types');
const ReactNative = require('ReactNative');
// $FlowFixMe

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

@mottox2
mottox2 force-pushed the flow-touchable-native-feedback branch from 1996e49 to 4623d51 Compare November 7, 2018 01:48

@RSNara RSNara left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍🏽

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

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.

@RSNara RSNara left a comment

Copy link
Copy Markdown
Contributor

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. 😅

},

_handleDelay: function(e) {
_handleDelay: function(e: LayoutEvent) {

Copy link
Copy Markdown
Contributor

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?

},

_handleLongDelay: function(e) {
_handleLongDelay: function(e: LayoutEvent) {

Copy link
Copy Markdown
Contributor

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.

},

_savePressInLocation: function(e) {
_savePressInLocation: function(e: LayoutEvent) {

Copy link
Copy Markdown
Contributor

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.

},

_endHighlight: function(e) {
_endHighlight: function(e: LayoutEvent) {

Copy link
Copy Markdown
Contributor

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?

},

_startHighlight: function(e) {
_startHighlight: function(e: LayoutEvent) {

Copy link
Copy Markdown
Contributor

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,
) {

Copy link
Copy Markdown
Contributor

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?

* @sideeffects
*/
_receiveSignal: function(signal, e) {
_receiveSignal: function(signal: Signal, e: LayoutEvent) {

Copy link
Copy Markdown
Contributor

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?

*
*/
touchableHandleResponderGrant: function(e) {
touchableHandleResponderGrant: function(e: SyntheticEvent<any>) {

Copy link
Copy Markdown
Contributor

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.

* Place as callback for a DOM element's `onResponderTerminate` event.
*/
touchableHandleResponderTerminate: function(e) {
touchableHandleResponderTerminate: function(e: PressEvent) {

Copy link
Copy Markdown
Contributor

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.

@react-native-bot

Copy link
Copy Markdown
Collaborator

@mottox2 merged commit 3649a50 into facebook:master.

@react react locked as resolved and limited conversation to collaborators Nov 21, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Nov 21, 2018
t-nanava pushed a commit to microsoft/react-native-macos that referenced this pull request Jun 17, 2019
Summary:
Related to react#22100

Turn Flow strict mode on for Libraries/Components/Touchable/TouchableNativeFeedback.android.js.
Pull Request resolved: react#22176

Reviewed By: TheSavior

Differential Revision: D13033239

Pulled By: RSNara

fbshipit-source-id: 57e89ce16040e6238e01e0437327db943a5f2581
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: TouchableNativeFeedback Flow Merged This PR has been merged. Platform: Android Android applications.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants