From 8b93c6cd5b697a264d1609f86051bb2392c698b8 Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Sat, 10 Nov 2018 19:27:38 -0500 Subject: [PATCH] react-navigation: Make declarations work with strictFunctionTypes. Believed to fix https://stackoverflow.com/q/53154003. This reverts 4464cbbfe725bfc191006e41cbe634dc87b8baaa. I was unable to reproduce the issue that that commit was originally trying to fix. Without reverting it, the BackButtonWithNavigationWithExplicitProps test fails on typescript@next. --- types/react-navigation/index.d.ts | 26 +++++++++---------- .../react-navigation-tests.tsx | 4 +-- types/react-navigation/tsconfig.json | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 846ea56a9e..15e72b6b61 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -1248,17 +1248,17 @@ export interface NavigationInjectedProps

{ } // If the wrapped component is a class, we can get a ref to it -export function withNavigation>( - Component: T, -): React.ComponentType, keyof NavigationInjectedProps> & { onRef?: React.Ref> }>; +export function withNavigation

>( + Component: T & React.ComponentClass

, +): React.ComponentType & { onRef?: React.Ref> }>; -export function withNavigation>( - Component: T, -): React.ComponentType, keyof NavigationInjectedProps>>; +export function withNavigation

( + Component: React.ComponentType

, +): React.ComponentType>; // For backwards compatibility export function withNavigation( - Component: React.ComponentType)>, + Component: React.ComponentType>, ): React.ComponentType>> }>; export interface NavigationFocusInjectedProps

extends NavigationInjectedProps

{ @@ -1266,13 +1266,13 @@ export interface NavigationFocusInjectedProps

extends Navi } // If the wrapped component is a class, we can get a ref to it -export function withNavigationFocus>( - Component: T, -): React.ComponentType, keyof NavigationFocusInjectedProps> & { onRef?: React.Ref> }>; +export function withNavigationFocus

>( + Component: T & React.ComponentClass

, +): React.ComponentType & { onRef?: React.Ref> }>; -export function withNavigationFocus>( - Component: T, -): React.ComponentType, keyof NavigationFocusInjectedProps>>; +export function withNavigationFocus

( + Component: React.ComponentType

, +): React.ComponentType>; // For backwards compatibility export function withNavigationFocus( diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index e568fbed27..ba77442a40 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -383,14 +383,14 @@ class CustomTransitioner extends React.Component /> ); } - _render = (props: NavigationTransitionProps, prevProps: NavigationTransitionProps): React.ReactElement => { + _render = (props: NavigationTransitionProps, prevProps?: NavigationTransitionProps): React.ReactElement => { return ( ); } _configureTransition = ( _transitionProps: NavigationTransitionProps, - _prevTransitionProps: NavigationTransitionProps + _prevTransitionProps?: NavigationTransitionProps ) => { return {}; } diff --git a/types/react-navigation/tsconfig.json b/types/react-navigation/tsconfig.json index b0cf7029db..bc49bee237 100644 --- a/types/react-navigation/tsconfig.json +++ b/types/react-navigation/tsconfig.json @@ -7,7 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strictFunctionTypes": false, + "strictFunctionTypes": true, "baseUrl": "../", "jsx": "react", "typeRoots": [