Skip to content

Commit

Permalink
[flow] Update libdef for 3.0 (#5234)
Browse files Browse the repository at this point in the history
1. `navigationOptions` in `RouteConfig`s is now `defaultNavigationOptions`
2. `create*Navigator` no longer return a container, they return a navigator
3. Introducing `createAppContainer`

Closes #4722 by including flow-typed/flow-typed#2522
  • Loading branch information
Ashoat committed Nov 15, 2018
1 parent 0d8af72 commit e060154
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions flow/react-navigation.js
Expand Up @@ -293,7 +293,7 @@ declare module 'react-navigation' {

declare export type NavigationComponent =
| NavigationScreenComponent<NavigationRoute, *, *>
| NavigationContainer<*, *, *>;
| NavigationNavigator<*, *, *>;

declare interface withOptionalNavigationOptions<Options> {
navigationOptions?: NavigationScreenConfig<Options>;
Expand All @@ -317,7 +317,7 @@ declare module 'react-navigation' {
State: NavigationState,
Options: {},
Props: {}
> = React$ComponentType<{
> = React$StatelessFunctionalComponent<{
...Props,
...NavigationNavigatorProps<Options, State>,
}> &
Expand Down Expand Up @@ -396,7 +396,7 @@ declare module 'react-navigation' {
initialRouteName?: string,
initialRouteParams?: NavigationParams,
paths?: NavigationPathsConfig,
navigationOptions?: NavigationScreenConfig<*>,
defaultNavigationOptions?: NavigationScreenConfig<*>,
initialRouteKey?: string,
|};

Expand Down Expand Up @@ -431,7 +431,7 @@ declare module 'react-navigation' {
initialRouteName?: string,
initialRouteParams?: NavigationParams,
paths?: NavigationPathsConfig,
navigationOptions?: NavigationScreenConfig<*>,
defaultNavigationOptions?: NavigationScreenConfig<*>,
order?: Array<string>,
backBehavior?: 'none' | 'initialRoute', // defaults to `'none'`
resetOnBlur?: boolean, // defaults to `true`
Expand All @@ -445,7 +445,7 @@ declare module 'react-navigation' {
initialRouteName?: string,
initialRouteParams?: NavigationParams,
paths?: NavigationPathsConfig,
navigationOptions?: NavigationScreenConfig<*>,
defaultNavigationOptions?: NavigationScreenConfig<*>,
// todo: type these as the real route names rather than 'string'
order?: Array<string>,
// Does the back button cause the router to switch to the initial tab
Expand Down Expand Up @@ -761,6 +761,9 @@ declare module 'react-navigation' {
* Now we type the actual exported module
*/

declare export function createAppContainer<S: NavigationState, O: {}>(
Component: NavigationNavigator<S, O, *>
): NavigationContainer<S, O, *>;
declare export function createNavigationContainer<S: NavigationState, O: {}>(
Component: NavigationNavigator<S, O, *>
): NavigationContainer<S, O, *>;
Expand Down Expand Up @@ -892,11 +895,11 @@ declare module 'react-navigation' {
declare export function StackNavigator(
routeConfigMap: NavigationRouteConfigMap,
stackConfig?: StackNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;
declare export function createStackNavigator(
routeConfigMap: NavigationRouteConfigMap,
stackConfig?: StackNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;

declare type _TabViewConfig = {|
tabBarComponent?: React$ElementType,
Expand All @@ -920,31 +923,31 @@ declare module 'react-navigation' {
declare export function TabNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _TabNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;
declare export function createTabNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _TabNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;
/* TODO: fix the config for each of these tab navigator types */
declare export function createBottomTabNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _TabNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;
declare export function createMaterialTopTabNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _TabNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;
declare type _SwitchNavigatorConfig = {|
...NavigationSwitchRouterConfig,
|};
declare export function SwitchNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _SwitchNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;
declare export function createSwitchNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _SwitchNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;

declare type _DrawerViewConfig = {|
drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open',
Expand All @@ -965,11 +968,11 @@ declare module 'react-navigation' {
declare export function DrawerNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _DrawerNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;
declare export function createDrawerNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _DrawerNavigatorConfig
): NavigationContainer<*, *, *>;
): NavigationNavigator<*, *, *>;

declare export function StackRouter(
routeConfigs: NavigationRouteConfigMap,
Expand Down

0 comments on commit e060154

Please sign in to comment.