diff --git a/src/types.ts b/src/types.ts index 334cb5084..848fce1aa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -93,6 +93,9 @@ export type ConnectPropsMaybeWithoutContext = ? Omit : ConnectProps +type Identity = T +export type Mapped = Identity<{ [k in keyof T]: T[k] }> + // Injects props and removes them from the prop requirements. // Will not pass through the injected props if they are passed in during // render. Also adds new prop requirements from TNeedsProps. @@ -105,12 +108,14 @@ export type InferableComponentEnhancerWithProps = < component: C ) => ConnectedComponent< C, - DistributiveOmit< - GetLibraryManagedProps, - keyof Shared> - > & - TNeedsProps & - ConnectPropsMaybeWithoutContext> + Mapped< + DistributiveOmit< + GetLibraryManagedProps, + keyof Shared> + > & + TNeedsProps & + ConnectPropsMaybeWithoutContext> + > > // Injects props and removes them from the prop requirements. diff --git a/test/typetests/connect-options-and-issues.tsx b/test/typetests/connect-options-and-issues.tsx index 48f49dd8e..9e1260e8f 100644 --- a/test/typetests/connect-options-and-issues.tsx +++ b/test/typetests/connect-options-and-issues.tsx @@ -465,7 +465,7 @@ function TestOptionalPropsMergedCorrectly() { } } - connect(mapStateToProps, mapDispatchToProps)(Component) + const Connected = connect(mapStateToProps, mapDispatchToProps)(Component) } function TestMoreGeneralDecorationProps() {