Skip to content

@types/react-redux is incorrect for mergeProps when mapDispatchToProps is null/undefined #1877

@saraid

Description

@saraid

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React:
  • ReactDOM/React Native:
  • Redux:
  • React Redux:

What is the current behavior?

Discussed here: DefinitelyTyped/DefinitelyTyped#59297

The error is that the types do not consider a code-supported case where mergeProps is defined, but mapDispatchToProps is not. The types expect that the passed value will be undefined, whereas the code actually passes { dispatch: Dispatch }.

This means that, when the Typescript option strictFunctionTypes is set to true, correctly typed usages of this pattern will fail.

What is the expected behavior?

When turning strictFunctionTypes on, the types should still compile for this specific use case. A PR has been opened to fix the issue.

I was asked to file this issue to make sure it gets tracked for v8 development.

Which browser and OS are affected by this issue?

No response

Did this work in previous versions of React Redux?

  • Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions