react-use icon indicating copy to clipboard operation
react-use copied to clipboard

createReducer not working with Typescript (type def errors showing up)

Open Deviad opened this issue 6 years ago • 3 comments

What is the current behavior? At the moment if you use useReducer as in the documentation you get weird errors when using Typescript: image

What is the expected behavior? It should work without complaining

A little about versions:

  • Typescript 3.5.3 - Typescript 3.7.4
  • OS: Mojave
  • Browser (vendor and version):
  • React:
  • react-use: 13.12.2 - 13.13.0
  • redux-thunk: 2.3.0
  • redux: 4.0.4
  • @types/react-redux: 7.1.1 - 7.1.5

Deviad avatar Dec 30 '19 20:12 Deviad

The issue seems to be that redux' dispatch returns the action: https://github.com/reduxjs/redux/blob/master/src/types/store.ts#L83

Whereas react-use's dispatch returns void: https://github.com/streamich/react-use/blob/master/src/factory/createReducer.ts#L4

Would it match the intentions of this library to align this with redux, perhaps use redux typings? Alternatively the Dispatch typing in react-use could be changed to return any to make it more agnostic.

n4bb12 avatar Feb 10 '21 19:02 n4bb12

can i work on this issue ?

ItZmEkAtHiR avatar Oct 30 '23 06:10 ItZmEkAtHiR