feat: make ScreenProps parametrizable in TypeScript (#6496)

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 commit is contained in:
William Candillon
2020-01-23 15:41:22 +01:00
parent 0189ff4eb3
commit 5d3fd5bea0

View File

@@ -482,7 +482,7 @@ declare module 'react-navigation' {
| NavigationSwitchAction
| { type: 'CHILD_ACTION'; key?: string };
export type NavigationRouteConfig<Options, NavigationScreenPropType> =
export type NavigationRouteConfig<Options, NavigationScreenPropType, ScreenProps = unknown> =
| NavigationComponent<Options, NavigationScreenPropType>
| (
| { screen: NavigationComponent<Options, NavigationScreenPropType> }
@@ -494,7 +494,8 @@ declare module 'react-navigation' {
}) & {
navigationOptions?: NavigationScreenConfig<
Options,
NavigationScreenPropType
NavigationScreenPropType,
ScreenProps
>;
params?: { [key: string]: any };
path?: string;
@@ -514,10 +515,11 @@ declare module 'react-navigation' {
resetOnBlur?: boolean;
}
export interface NavigationRouteConfigMap<Options, NavigationScreenPropType> {
export interface NavigationRouteConfigMap<Options, NavigationScreenPropType, ScreenProps = unknown> {
[routeName: string]: NavigationRouteConfig<
Options,
NavigationScreenPropType
NavigationScreenPropType,
ScreenProps
>;
}