From 8869c6e72ec2c9307ed7cc05ef157eebbdaedd13 Mon Sep 17 00:00:00 2001 From: Serge Lebedev Date: Wed, 6 Jun 2018 01:19:12 +0600 Subject: [PATCH] [flow] Fix NavigationScreenComponent's navigationOptions (#4317) --- .../react-navigation/flow/react-navigation.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/react-navigation/flow/react-navigation.js b/packages/react-navigation/flow/react-navigation.js index 17813fe9..0234115b 100644 --- a/packages/react-navigation/flow/react-navigation.js +++ b/packages/react-navigation/flow/react-navigation.js @@ -283,6 +283,10 @@ declare module 'react-navigation' { | NavigationScreenComponent | NavigationContainer<*, *, *>; + declare interface withOptionalNavigationOptions { + navigationOptions?: NavigationScreenConfig, + } + declare export type NavigationScreenComponent< Route: NavigationRoute, Options: {}, @@ -290,8 +294,11 @@ declare module 'react-navigation' { > = React$ComponentType<{ ...Props, ...NavigationNavigatorProps, - }> & - ({} | { navigationOptions: NavigationScreenConfig }); + }> & withOptionalNavigationOptions; + + declare interface withRouter { + router: NavigationRouter, + } declare export type NavigationNavigator< State: NavigationState, @@ -300,10 +307,7 @@ declare module 'react-navigation' { > = React$ComponentType<{ ...Props, ...NavigationNavigatorProps, - }> & { - router: NavigationRouter, - navigationOptions?: ?NavigationScreenConfig, - }; + }> & withRouter & withOptionalNavigationOptions; declare export type NavigationRouteConfig = | NavigationComponent @@ -549,10 +553,7 @@ declare module 'react-navigation' { > = React$ComponentType<{ ...Props, ...NavigationContainerProps, - }> & { - router: NavigationRouter, - navigationOptions?: ?NavigationScreenConfig, - }; + }> & withRouter & withOptionalNavigationOptions; declare export type NavigationContainerProps = $Shape<{ uriPrefix?: string | RegExp,