diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 237813ec0d..89ffec3a09 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -592,10 +592,10 @@ export namespace NavigationActions { * BEGIN CUSTOM CONVENIENCE INTERFACES */ -export interface NavigationScreenProps { - navigation: NavigationScreenProp, NavigationAction>, - screenProps: { [key: string]: any }, - navigationOptions: any, +export interface NavigationScreenProps { + navigation: NavigationScreenProp, NavigationAction>, + screenProps?: { [key: string]: any }, + navigationOptions?: NavigationScreenConfig, } /** diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 3a4e02a16c..5fe48aef1b 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -19,15 +19,15 @@ import { * @desc Simple screen component class with typed component props that should * receive the navigation prop from the AppNavigator. */ -interface StartScreenComponentProps { +interface StartScreenNavigationParams { id: number, s: string, } -interface StartScreenProps extends NavigationScreenProps { } +interface StartScreenProps extends NavigationScreenProps { } class StartScreen extends React.Component { render() { // Implicit type checks. - const navigationStateParams: StartScreenComponentProps = this.props.navigation.state.params; + const navigationStateParams: StartScreenNavigationParams = this.props.navigation.state.params; const id = this.props.navigation.state.params.id; const s = this.props.navigation.state.params.s; @@ -43,7 +43,7 @@ class StartScreen extends React.Component { { id: this.props.navigation.state.params.id, name: this.props.navigation.state.params.s, - } as NextScreenComponentProps, + } as NextScreenNavigationParams, ); } @@ -53,15 +53,15 @@ class StartScreen extends React.Component { * @class NextScreen @extends React.Component */ const ROUTE_NAME_NEXT_SCREEN = "NextScreen"; -interface NextScreenComponentProps { +interface NextScreenNavigationParams { id: number, name: string, } -interface NextScreenProps extends NavigationScreenProps { } +interface NextScreenProps extends NavigationScreenProps { } class NextScreen extends React.Component { render() { // Implicit type checks. - const navigationStateParams: NextScreenComponentProps = this.props.navigation.state.params; + const navigationStateParams: NextScreenNavigationParams = this.props.navigation.state.params; const id = this.props.navigation.state.params.id; const name = this.props.navigation.state.params.name; @@ -71,6 +71,10 @@ class NextScreen extends React.Component { } } +const initialRouteParams: StartScreenNavigationParams = { + id: 1, + s: "Start", +}; export const AppNavigator = StackNavigator({ StartImage: { path: 'startImage', @@ -78,6 +82,7 @@ export const AppNavigator = StackNavigator({ }, }, { initialRouteName: 'StartImage', + initialRouteParams, }); const Router = (props: any) => (