From c8e56731835ff6fe2961968da1bc945169f7bfa8 Mon Sep 17 00:00:00 2001 From: Ashoat Tevosyan Date: Fri, 15 Jun 2018 02:33:50 +0800 Subject: [PATCH] [flow] Type getNavigation (#4505) Unrelated change in here: typing `tabBarOnPress`'s `defaultHandler`. Wasn't sure if I should make a separate PR for a single unrelated line, let me know if you'd prefer that going forward. --- flow/react-navigation.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/flow/react-navigation.js b/flow/react-navigation.js index 0234115..272194d 100644 --- a/flow/react-navigation.js +++ b/flow/react-navigation.js @@ -284,7 +284,7 @@ declare module 'react-navigation' { | NavigationContainer<*, *, *>; declare interface withOptionalNavigationOptions { - navigationOptions?: NavigationScreenConfig, + navigationOptions?: NavigationScreenConfig; } declare export type NavigationScreenComponent< @@ -294,10 +294,11 @@ declare module 'react-navigation' { > = React$ComponentType<{ ...Props, ...NavigationNavigatorProps, - }> & withOptionalNavigationOptions; + }> & + withOptionalNavigationOptions; declare interface withRouter { - router: NavigationRouter, + router: NavigationRouter; } declare export type NavigationNavigator< @@ -307,7 +308,9 @@ declare module 'react-navigation' { > = React$ComponentType<{ ...Props, ...NavigationNavigatorProps, - }> & withRouter & withOptionalNavigationOptions; + }> & + withRouter & + withOptionalNavigationOptions; declare export type NavigationRouteConfig = | NavigationComponent @@ -449,6 +452,7 @@ declare module 'react-navigation' { tabBarTestIDProps?: { testID?: string, accessibilityLabel?: string }, tabBarOnPress?: ({ navigation: NavigationScreenProp, + defaultHandler: () => void, }) => void, |}; @@ -553,7 +557,9 @@ declare module 'react-navigation' { > = React$ComponentType<{ ...Props, ...NavigationContainerProps, - }> & withRouter & withOptionalNavigationOptions; + }> & + withRouter & + withOptionalNavigationOptions; declare export type NavigationContainerProps = $Shape<{ uriPrefix?: string | RegExp, @@ -1162,4 +1168,13 @@ declare module 'react-navigation' { declare export function withNavigationFocus( Component: React$ComponentType ): React$ComponentType<$Diff>; + + declare export function getNavigation( + router: NavigationRouter, + state: State, + dispatch: NavigationDispatch, + actionSubscribers: Set, + getScreenProps: () => {}, + getCurrentNavigation: () => NavigationScreenProp + ): NavigationScreenProp; }