diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 241232227e..f86a47ccf5 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -173,13 +173,14 @@ export type NavigationScreenConfig = }) => Options); export type NavigationComponent = - NavigationScreenComponent + NavigationScreenComponent | NavigationNavigator; export type NavigationScreenComponent< + Params = NavigationParams, Options = {}, Props = {} -> = React.ComponentType & Props> & +> = React.ComponentType & Props> & { navigationOptions?: NavigationScreenConfig }; export type NavigationNavigator< @@ -429,17 +430,17 @@ export interface NavigationScreenProp { goBack: (routeKey?: string | null) => boolean; navigate(options: { routeName: string; - params?: P; + params?: NavigationParams; action?: NavigationAction; key?: string; }): boolean; navigate( routeNameOrOptions: string, - params?: P, + params?: NavigationParams, action?: NavigationAction, ): boolean; getParam: (param: T, fallback?: P[T]) => P[T]; - setParams: (newParams: NavigationParams) => boolean; + setParams: (newParams: P) => boolean; addListener: ( eventName: string, callback: NavigationEventCallback @@ -859,10 +860,10 @@ export function createNavigationContainer( * BEGIN CUSTOM CONVENIENCE INTERFACES */ -export interface NavigationScreenProps { - navigation: NavigationScreenProp>; +export interface NavigationScreenProps { + navigation: NavigationScreenProp, Params>; screenProps?: { [key: string]: any }; - navigationOptions?: NavigationScreenConfig; + navigationOptions?: NavigationScreenConfig; } /** diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index d70bca3ecd..7e956d2c1a 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -134,7 +134,12 @@ export const AppNavigator = StackNavigator( }, ); -const StatelessScreen: NavigationScreenComponent = () => ; +interface StatelessScreenParams { + testID: string; +} + +const StatelessScreen: NavigationScreenComponent = (props) => + ; StatelessScreen.navigationOptions = { title: 'Stateless' };