[Flow202][native][skip-ci] [13/x] Enable NavigationHelpersContext to parameterize on invocation
Summary:
One of the quirks of Flow is that the only way to type a React component in a way where the types are parameterized on invocation is to type it as a function.
In our codebase, we render NavigationHelpersContext.Provider inside OverlayNavigator. In that context, in order for the types to match, we need the NavigationHelpersContext.Provider to be able to take a type that is more specific than NavigationHelpers<ParamListBase>.
I initially tried to address this by convincing Flow that the more specific type (OverlayNavigationHelpers<ParamList>) is a subtype of the more general type (NavigationHelpers<ParamListBase>). However, this turned out to be impossible because of a covariance / contravariance issue. Because this type param is used within NavigationHelpersContext.Provider in both "in" and "out" contexts, the type param must match exactly for the subtype relationship to work.
Instead, I concluded that I had to parameterize NavigationHelpersContext.Provider. I started out by looking up the Flow types for React.Context here.
I then implemented an alternate type that matches React.Context, but uses functions with type params in place of React.ComponentType in the Provider and Consumer definitions. With this change, Flow is properly able to match up the types for NavigationHelpersContext.Provider.
Depends on D9996
Test Plan: Confirm the Flow errors go away
Reviewers: tomek
Reviewed By: tomek
Differential Revision: https://phab.comm.dev/D9997