Page MenuHomePhabricator

[Flow202][native][skip-ci] [20/x] Update Reanimated libdef to match GestureHandler
ClosedPublic

Authored by ashoat on Nov 27 2023, 12:37 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 22, 10:14 AM
Unknown Object (File)
Sun, Dec 22, 10:14 AM
Unknown Object (File)
Sun, Dec 22, 10:14 AM
Unknown Object (File)
Sun, Dec 22, 10:13 AM
Unknown Object (File)
Sun, Dec 22, 10:13 AM
Unknown Object (File)
Fri, Dec 20, 1:26 PM
Unknown Object (File)
Wed, Dec 18, 4:02 PM
Unknown Object (File)
Tue, Dec 10, 7:47 AM
Subscribers
None

Details

Summary

Separating this diff out since there are some significant changes to useAnimatedGestureHandler here, which is a hook from react-native-reanimated.

In fact this hook does not return a function. However, the TypeScript types for react-native-gesture-handler requires that onGestureEvent takes a function. As a result, in the linked code you can see that react-native-reanimated types the return of useAnimatedGestureHandler as a function, even though it is not. We do the same here.

I'll annotate some of the changes in this diff inline.

NOTE: CI will fail on this diff. I considered the possibility of fixing Flow errors BEFORE upgrading Flow, but it wasn't possible... in some cases, the fixes to support the new version of Flow caused errors in the old version. I could have hidden these type errors with $FlowFixMe lines and then later revert those, but that seemed like too much busy work.

Depends on D10003

Test Plan

Confirm the Flow errors go away

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 24553
Build 211050: arc lint + arc unit

Event Timeline

ashoat created this revision.
lib/types/react-types.js
8 ↗(On Diff #33648)

I wasn't able to find a type for this in Flow's lib for React, but I'll revisit and confirm this before landing

native/chat/swipeable-message.react.js
207–210 ↗(On Diff #33648)

I needed to add this because of the way ctx is typed as a generic object

native/flow-typed/npm/react-native-gesture-handler_v2.x.x.js
382–383 ↗(On Diff #33648)

This wasn't relevant to the Flow upgrade... just updated the array case to $ReadOnlyArray

native/flow-typed/npm/react-native-reanimated_v2.x.x.js
459–468 ↗(On Diff #33648)

These changes are mainly to extract EventResult so it can be exported. I also added a default type for the second type param

477 ↗(On Diff #33648)

I added a default type for the second type param

487 ↗(On Diff #33648)

This is a significant change. See my notes from the description:

In fact this hook does not return a function. However, the TypeScript types for react-native-gesture-handler requires that onGestureEvent takes a function. As a result, in the linked code you can see that react-native-reanimated types the return of useAnimatedGestureHandler as a function, even though it is not. We do the same here.

This revision is now accepted and ready to land.Nov 27 2023, 6:47 AM

Use Flow's comment syntax for typehints in useAnimatedGestureHandler, as all the callbacks passed there are implicitly Reanimated worklets