-
-
Notifications
You must be signed in to change notification settings - Fork 655
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
Add Flow types required for RN 0.59 migration #3442
Conversation
c77a7c7
to
0078479
Compare
@gnprice this should be ready to merge independently of RN 0.59 |
Thanks @borisyankov ! These look like good improvements in general, in addition to being required by the newer Flow 😄 Small comments:
Not a blocker to merge, but a followup-thought that this brought to mind: where we're writing types that really belong to RN, or to another third-party library, the ideal place for them would actually be in a libdef, rather than inside our app code. We generally haven't done that because we get most of our libdefs from the |
a0a61cd
to
8a08d8e
Compare
Thanks again @borisyankov ! You mentioned this PR in an audio conversation the other day, so I came back to look at it. It looks like you've resolved the lint errors; but my other comment is still outstanding:
Would you please address that? Looking forward to getting to merge this 🙂 |
Also, I'll just add a link here to make this PR discoverable directly from the issue: this is part of #3399 . |
0377fbc
to
b087730
Compare
This is ready for review and merge, separately from the RN 0.59 PR. The changes are mostly minor commit message improvements but also this commit is new: |
b087730
to
dc6b5e5
Compare
Thanks for these revisions. The new commit looks great. In the places I requested changes, I'm disappointed because it looks as if you didn't really read what I said or make much effort to respond. This matters to me because it means I feel like I wasn't heard. I'll follow up with you separately. In this instance, the requested changes are pretty straightforward to make; so I'll go ahead and merge, perhaps with some adjustments. |
`UserItem` component and several related ones, when using an `onPress` callback, were passing an object consisting of `email` and `fullName` of the user being selected, and a variety of callbacks used one or the other. Trying to type this more precisely and 'strict'-ly revealed that we are treating this object rather loosely. The `fullName` info was almost never used. So, we omit it. This is a pure refactor that removes the `fullName` information and keeps the `email` as a string instead of property of an object. Only `PeopleAutocomplete` is slightly reworked to get the `fullName` via the `email` value, a trivial `find` in an array of users.
This does not exist as a Flow type in React Native, so we can't import it. But we can just define it ourselves. Documentation at: https://facebook.github.io/react-native/docs/appstate
While documented, this type is not explicitly defined in the RN's source files. So we define it locally and reuse. Documentation: https://facebook.github.io/react-native/docs/netinfo
The linked docs page uses the name `ConnectionType` specifically for the enum found in the `type` property of this type. The other property's type is `EffectiveConnectionType`. The object type containing both isn't given a name, but parameters of that type are called `connectionInfo`, which seems apt. So, avoid reusing the upstream docs' name `ConnectionType` for something related but different, which risks being quite confusing. Also move the type from the global `types.js` to the one place where we refer to it, so there isn't such a general name floating around in basically our global namespace; and add a TODO to move it to a still more appropriate spot, namely a libdef.
The `LinkingEvent` type does not exist explicitly in React Native's code and was confirmed correct by reading the source code and looking at the documentation in: https://facebook.github.io/react-native/docs/linking `getInitialURL` returns only `string` or `null` but is already internally defined as `?string` in RN so use that instead.
This is information that was in the commit messages of the commits that added these bits of code. It's useful information, and important not only for understanding the change (i.e. for comparing old and new versions of the code), but instead mainly for understanding the new code as it is. So, the best place for it is in comments on the code itself, right in the tree.
Add type for the object we use for language meta-data and a type for the exported value based on it.
Using the newly typed exports in 'languages.js' add types to the code that uses that data.
Import `LayoutEvent` from the semi-obscure place it is defined and use it to type the layout event handler.
Adds very minor types to several files that would result in errors in upcoming Flow versions.
And merged! Thanks again. |
Fixes zulip#3399! The bulk of the work of this upgrade went into a large number of commits previous to this one. The majority of the last few dozen commits, after 1c86488^, were part of the upgrade; some discussion in zulip#3561. An earlier wave of effort focused on getting things working with the upgrade of Flow to v0.92; see zulip#3450 and especially f8c9810, and then zulip#3453 and zulip#3442. Some other early discussion is at zulip#3422. This commit itself was done mainly by running: $ tools/upgrade rn v0.59.10 Then, that tool needs a bit of an update for changes upstream. Because I'm feeling pressed to get this upgrade out the door (and to deal with the various separate trouble on iOS), I just took care of the other relevant packages by hand: updated `@babel/core` and `metro-react-native-babel-preset` in package.json according to the diff seen in `rn-diff-purge`, then reran `yarn`.
This PR adds Flow types that if missing, result in errors in the React Native 0.59 upgrade PR (not because of RN but because of Flow 0.92)
Can be merged separately. Prerequisite for #3422