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-related work on the path to RN v0.64 upgrade, part 4. #4891

Merged
merged 5 commits into from
Jul 13, 2021

Conversation

chrisbobbe
Copy link
Contributor

@chrisbobbe chrisbobbe commented Jul 9, 2021

Parts 1, 2, and 3 were #4518, #4520, and #4836.

This doesn't upgrade Flow at all or add any new config; it's just cleaning up some stuff that I noticed (one commit is another round like #4433, for example). These kinds of small messes could easily creep back in before we add config to prevent them for good, but might as well sweep things up as we see them.

After this, the work I see before the RN v0.64 upgrade (#4426) is:

  • Types-first (as noted in the issue, we can probably do some selective suppressions there for now, but I'm not sure that'll hold in future Flow versions)
  • Turning on exact_by_default
  • (Maybe an issue with react-intl's libdef; see discussion)

For exact_by_default, I think I have a handle on all the little issues in our libraries' built-in Flow definitions, so that won't be hard unless new problems come up (e.g., with libraries or library versions we aren't using right now). One of those issues might best be solved with a small one-line PR to @react-native-community/cameraroll; hopefully they'd take it.

Flow v0.137, which we'll start using with the upcoming RN v0.64
upgrade (zulip#4426), seems to prefer it this way. I don't see it as
worse, for readability, so might as well.
Not totally sure why it wants this now; maybe because I changed the
text-wrap settings in VSCode a few weeks ago? Anyway, seems quite
harmless and fine.
This is another round in the spirit of zulip#4433, to prepare for Flow
v0.132 and later; there's this in the changelog entry [1]:

> Added warnings against suppressions without error codes

As we noted there, we still haven't enforced that suppressions have
error codes, but at least we can clean up these ones that have crept
in.

[1] https://github.com/facebook/flow/blob/master/Changelog.md#01320
Without this, when I try upgrading to Flow v0.137, for the upcoming
RN v0.64 upgrade, I get this error:

```
Error --------------------------------------------------------------------------------------- src/boot/reducers.js:73:33

Cannot call `maybeLogSlowReducer` with `key` bound to `key` because type variable `Key` [1] cannot escape from the scope
in which it was defined [2] (try adding a type annotation to `key` [3]). [escaped-generic]

   src/boot/reducers.js:73:33
   73|     maybeLogSlowReducer(action, key, startMs, endMs);
                                       ^^^

References:
   src/boot/reducers.js:43:8
   43|   key: Key,
              ^^^ [1]
   src/boot/reducers.js:42:23
   42| function applyReducer<Key: $Keys<GlobalState>, State>(
                             ^^^ [2]
   src/boot/reducers.js:36:38
   36| function maybeLogSlowReducer(action, key, startMs, endMs) {
                                            ^^^ [3]
```

I haven't reasoned all of the way through it yet, but the annotation
seems harmless and correct.
We already have a type wrapper for this function, from 8f56964, so
we could just as well have suppressed type-checking for this whole
function here. But this is easy.

The Flow error that caused me to notice this appeared when I tried
to upgrade to Flow v0.137, for the RN v0.64 upgrade:

```
Error -------------------------------------------------------- flow-typed/react-native-safe-area-context_vx.x.x.js:60:23

Cannot use `React.ComponentType` as a type because it is an `any`-typed value. Type `React.ComponentType` properly, so
it is no longer `any`-typed, to use it as an annotation. [value-as-type]

   60|     WrappedComponent: React.ComponentType<T>,
                             ^^^^^^^^^^^^^^^^^^^
```
@gnprice
Copy link
Member

gnprice commented Jul 13, 2021

Looks good, thanks! Merging.

@gnprice gnprice merged commit a55b0e9 into zulip:master Jul 13, 2021
@chrisbobbe chrisbobbe mentioned this pull request Sep 8, 2021
@chrisbobbe chrisbobbe deleted the pr-more-flow-rn-64 branch November 4, 2021 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants