From b9ec3a72df4e962189d81be701b8b861d900299f Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Thu, 22 Sep 2022 23:38:43 -0400 Subject: [PATCH] Use a `Mapped` type to simplify the final displayed types for components --- src/types.ts | 8 ++++++-- test/typetests/connect-options-and-issues.tsx | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/types.ts b/src/types.ts index 334cb5084..bd0e0cb74 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. @@ -109,8 +112,9 @@ export type InferableComponentEnhancerWithProps = < GetLibraryManagedProps, keyof Shared> > & - TNeedsProps & - ConnectPropsMaybeWithoutContext> + Mapped< + 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() {