Skip to content

Action creators passed to connect with bindActionCreators are not typesafe #110

@C-Higgins

Description

@C-Higgins
const actions = {
	test: () => 1, // Obviously not an action creator
}
const mapStateToProps = (state: RootState) => state
// No Errors
const mapDispatchToProps = (dispatch: Dispatch<RootAction>) => bindActionCreators(actions, dispatch)
const cnRoomWrapper = connect(mapStateToProps, mapDispatchToProps)(RoomWrapper)

However, there is an error if I explicity wrap the dispatch:

// Gives correct error
const mapDispatchToProps = (dispatch: Dispatch<RootAction>) => {
    test: () => dispatch(actions.test)
})

How can I validate that the correct actions are being passed to connect?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions