streamich / react-use

React Hooks — 👍
http://streamich.github.io/react-use
The Unlicense
41.76k stars 3.15k forks source link

[createReducer()] `Type 'void' is not assignable to type 'T'.ts(2345)` when used with redux-saga createSagaMiddleware() #1630

Open rtruong opened 3 years ago

rtruong commented 3 years ago

What is the current behavior?

When trying to use createReducer() with redux-saga createSagaMiddleware(), we get the following compilation error in TypeScript 3.8.3:

Argument of type 'SagaMiddleware<object>' is not assignable to parameter of type 'Middleware<EmptyAction<"DECREMENT"> | EmptyAction<"INCREMENT"> | EmptyAction<"SAGA_DECREMENT"> | EmptyAction<"SAGA_INCREMENT">, Readonly<...>>'.
  Types of parameters 'api' and 'store' are incompatible.
    Type 'Store<EmptyAction<"DECREMENT"> | EmptyAction<"INCREMENT"> | EmptyAction<"SAGA_DECREMENT"> | EmptyAction<"SAGA_INCREMENT">, Readonly<...>>' is not assignable to type 'MiddlewareAPI<Dispatch<AnyAction>, any>'.
      The types returned by 'dispatch(...)' are incompatible between these types.
        Type 'void' is not assignable to type 'T'.  TS2345

Demo repo here: http://github.com/rtruong/react-use-redux-saga-issue

What is the expected behavior?

Compiles without errors.

A little about versions:

wrf189 commented 3 years ago

Hi

rtruong commented 3 years ago

Any updates on this?

MaximilianHollis commented 2 years ago

I'm facing this issue as well.