Skip to content
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 strict in DatePickerAndroid.android.js, DatePickerAndroid.ios.js #22106

Closed
wants to merge 5 commits into from

Conversation

nissy-dev
Copy link
Contributor

@nissy-dev nissy-dev commented Nov 4, 2018

Related to #22100

Turn Flow strict mode on for DatePickerAndroid

Test Plan:

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

This error was happend #22101 #22048

Release Notes:

[GENERAL] [ENHANCEMENT] [Components/DatePickerAndroid/DatePickerAndroid.android.js] - Flow strict mode
[GENERAL] [ENHANCEMENT] [Components/DatePickerAndroid/DatePickerAndroid.ios.js] - Flow strict mode

@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 4, 2018
@nissy-dev
Copy link
Contributor Author

I got this error...

// Getters and setters can have side effects and are unsafe. (unsafe-getters-setters)
static get dismissedAction() {
    return 'dismissedAction';
}

I should add unsafe.enable_getters_and_setters in .flowconfig?

@empyrical
Copy link
Contributor

I am not quite sure why those are getters. (Perhaps in an earlier revision, they were getting things from NativeModules?)

But you should be able to change them to normal static properties like:

static dismissedAction = 'dismissedAction';

@nissy-dev
Copy link
Contributor Author

@empyrical
Thank you for advice! I fixed.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Nov 4, 2018
Copy link
Contributor

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

Choose a reason for hiding this comment

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

@TheSavior is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification.

@facebook-github-bot facebook-github-bot added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Nov 5, 2018
@elicwhite
Copy link
Member

We have two internal flow errors from this change:

Cannot call await with `DatePickerAndroid.open(...)` bound to `p` because property `action` is missing in `Promise` [1].
                                                   v-----------------------
  87|     const {action, year, month, day} = await DatePickerAndroid.open({
  88|       date: this._getDefaultStartDate(),
  89|       minDate: minDate,
  90|       maxDate: maximumDate,
  91|     });
      -----^
References:
  react-native/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js:35:33
  35|   async open(options: Options): Promise<DatePickerModuleOpen> {
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1]

It looks like it expects action as part of the resolved promise. Is that something native actually provides and the type should be including or does it seem like a bug in our callsites?

@nissy-dev nissy-dev changed the title Turn Flow strict mode on for DatePickerAndroid [flow-strict] Flow strict in DatePickerAndroid.android.js, DatePickerAndroid.ios.js Nov 6, 2018
@nissy-dev
Copy link
Contributor Author

nissy-dev commented Nov 6, 2018

I refer to these lines. I seem that the native provides action(always), year, month day.

* @param promise This will be invoked with parameters action, year,
* month (0-11), day, where action is {@code dateSetAction} or
* {@code dismissedAction}, depending on what the user did. If the action is
* dismiss, year, month and date are undefined.
*/

But, the error which you got happened in DatePickerAndroid.ios.js
In the case of ios, DatePickerAndroid.open() always return Promise.reject().
So, I fix in DatePickerAndroid.ios.js. Is it OK...?

Copy link
Contributor

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

Choose a reason for hiding this comment

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

@TheSavior has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@nissy-dev nissy-dev closed this Nov 27, 2018
@elicwhite
Copy link
Member

@nd-02110114, was there a reason that you closed this PR? We hadn't gotten a chance to finish landing it but it was on our radar. I'd still like to land it. :-/

@nissy-dev nissy-dev reopened this Nov 28, 2018
@nissy-dev
Copy link
Contributor Author

@TheSavior
I'm so sorry 🙇 Reopened!!

@react-native-bot
Copy link
Collaborator

@nd-02110114 merged commit 60f3b53 into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Dec 26, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Dec 26, 2018
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. 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