Merge pull request #21730 from Knagis/react-redux-connect-options

react-redux: fix Options generic type arguments in connect()
This commit is contained in:
Armando Aguirre
2017-11-27 16:24:57 -08:00
committed by GitHub
2 changed files with 12 additions and 8 deletions
+5 -5
View File
@@ -120,28 +120,28 @@ export interface Connect {
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
mapDispatchToProps: null | undefined,
mergeProps: null | undefined,
options: Options<TStateProps, TOwnProps>
options: Options<State, TStateProps, TOwnProps>
): InferableComponentEnhancerWithProps<DispatchProp<any> & TStateProps, TOwnProps>;
<no_state = {}, TDispatchProps = {}, TOwnProps = {}>(
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(
mapStateToProps: null | undefined,
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
mergeProps: null | undefined,
options: Options<no_state, TOwnProps>
options: Options<{}, TStateProps, TOwnProps>
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = {}>(
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
mergeProps: null | undefined,
options: Options<TStateProps, TOwnProps>
options: Options<State, TStateProps, TOwnProps>
): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>;
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}, State = {}>(
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
mergeProps: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>,
options: Options<TStateProps, TOwnProps, TMergedProps>
options: Options<State, TStateProps, TOwnProps, TMergedProps>
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
}
+7 -3
View File
@@ -247,22 +247,26 @@ namespace MapStateAndDispatchAndMerge {
}
namespace MapStateAndOptions {
interface State { state: string; }
interface OwnProps { foo: string }
interface StateProps { bar: number }
interface DispatchProps { dispatch: Dispatch<any> }
class TestComponent extends Component<OwnProps & StateProps & DispatchProps> {}
const mapStateToProps = () => ({
const mapStateToProps = (state: State) => ({
bar: 1
})
const Test = connect(
const areStatePropsEqual = (next: StateProps, current: StateProps) => true;
const Test = connect<StateProps, DispatchProps, OwnProps, State>(
mapStateToProps,
null,
null,
{
pure: true
pure: true,
areStatePropsEqual,
}
)(TestComponent)