From cb4c6994bb1ffc60ac0ed8aab44b87dc6ae066d2 Mon Sep 17 00:00:00 2001 From: "satyajit.happy" Date: Sun, 22 Sep 2019 00:29:42 +0200 Subject: [PATCH] fix: accept type parameter for screenProps --- .../typescript/react-navigation.d.ts | 55 +++++-------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/packages/react-navigation/typescript/react-navigation.d.ts b/packages/react-navigation/typescript/react-navigation.d.ts index f98fef56..8c04fd3d 100644 --- a/packages/react-navigation/typescript/react-navigation.d.ts +++ b/packages/react-navigation/typescript/react-navigation.d.ts @@ -190,16 +190,16 @@ declare module 'react-navigation' { navigationOptions?: NavigationScreenConfig; }; - export interface NavigationScreenConfigProps { + export interface NavigationScreenConfigProps { navigation: NavigationScreenPropType; - screenProps: unknown; + screenProps: ScreenProps; theme: SupportedThemes; } - export type NavigationScreenConfig = + export type NavigationScreenConfig = | Options | (( - navigationOptionsContainer: NavigationScreenConfigProps & { + navigationOptionsContainer: NavigationScreenConfigProps & { navigationOptions: Options; } ) => Options); @@ -542,12 +542,12 @@ declare module 'react-navigation' { dangerouslyGetParent: () => NavigationScreenProp | undefined; } - export interface NavigationNavigatorProps { + export interface NavigationNavigatorProps { theme?: SupportedThemes | 'no-preference'; detached?: boolean; - navigation?: NavigationProp; - screenProps?: unknown; - navigationOptions?: O; + navigation?: NavigationProp; + screenProps?: ScreenProps; + navigationOptions?: Options; } export type NavigatorType = @@ -555,7 +555,7 @@ declare module 'react-navigation' { | 'react-navigation/TABS' | 'react-navigation/DRAWER'; - export interface NavigationContainerProps { + export interface NavigationContainerProps { uriPrefix?: string | RegExp; /** * Controls whether the navigation container handles URLs opened via 'Linking' @@ -568,7 +568,7 @@ declare module 'react-navigation' { nextNavigationState: NavigationState, action: NavigationAction ) => void | null | undefined; - navigation?: NavigationScreenProp; + navigation?: NavigationScreenProp; /* * This prop is no longer supported. Use `loadNavigationState` and * `persistNavigationState` instead. @@ -579,8 +579,8 @@ declare module 'react-navigation' { persistNavigationState?: (state: NavigationState) => Promise; renderLoadingExperimental?: React.ComponentType; - screenProps?: unknown; - navigationOptions?: O; + screenProps?: ScreenProps; + navigationOptions?: Options; style?: StyleProp; } @@ -613,9 +613,6 @@ declare module 'react-navigation' { backBehavior?: 'none' | 'initialRoute'; } - // Return createNavigationContainer - export type _SwitchNavigatorConfig = NavigationSwitchRouterConfig; - export function createSwitchNavigator( routeConfigMap: NavigationRouteConfigMap>, switchConfig?: SwitchNavigatorConfig @@ -738,11 +735,11 @@ declare module 'react-navigation' { getComponent: () => React.ComponentType; } - export type NavigationView = React.ComponentType< + export type NavigationView = React.ComponentType< { descriptors: { [key: string]: NavigationDescriptor }; - navigationConfig: O; - screenProps?: unknown; + navigationConfig: Options; + screenProps?: ScreenProps; } & NavigationInjectedProps >; @@ -779,28 +776,6 @@ declare module 'react-navigation' { Component: NavigationNavigator ): NavigationContainer; - /** - * END MANUAL DEFINITIONS OUTSIDE OF TYPEDEFINITION.JS - */ - - /** - * BEGIN CUSTOM CONVENIENCE INTERFACES - */ - - export interface NavigationScreenProps< - Params = NavigationParams, - Options = {}, - NavigationScreenPropType = NavigationScreenProp - > { - navigation: NavigationScreenProp, Params>; - screenProps?: unknown; - navigationOptions?: NavigationScreenConfig; - } - - /** - * END CUSTOM CONVENIENCE INTERFACES - */ - export type Omit = Pick>; export type InferProps<