This change allows for the following to be written:
```tsx
const TreatmentPlanDrawerItem = createStackNavigator(
{
Screen: {
screen: Screen,
// t is of type i18next.TFunction via the type casting below.
navigationOptions: ({ screenProps }) => ({
title: screenProps.t('title'),
})
},
} as NavigationRouteConfigMap<
NavigationStackOptions,
NavigationStackProp<NavigationRoute, any>,
{ t: i18next.TFunction }
>
);
```
This code is actually throwing a type error because of a wrong type declaration with the action expecting to be only a `NavigationNavigateAction` while in reality any action can be dispatched not only the `navigate`.
```jsx
StackActions.replace({
routeName: 'MyRoute1',
// this action is throwing a type error
action: StackActions.push({
routeName: 'MyRoute2',
}),
}),
```
Motivation
We can type navigation params in component by writing something like this in component props declaration :
export interface SomeNavigationParams {
foo: string;
bar: number;
}
export interface Props {
navigation: NavigationScreenProp<any, SomeNavigationParams>;
}
But when we are navigating to this screen, we only call navigate method without any type checking.
// Next line doesn't trigger ts error
this.props.navigation.navigate('MyRouteName', { foo: "foo", bar: "bar"})
By making navigate a generic method, we can type those params correctly
import { SomeNavigationParams } from '@Screens/....../SomeScreen.types.ts'
......
// Next line triggers an error
this.props.navigation.navigate<SomeNavigationParams>('MyRouteName', { foo: "foo", bar: "bar"});
......
Test plan
No .js code so it's can't be breaking anything. Plus, can't also break typing as changes are seamless for react-navigation API.