agiledigital / typed-redux-saga

An attempt to bring better TypeScript typing to redux-saga.
MIT License
314 stars 33 forks source link

Question: Is putResolve typed correctly? #351

Open chmac opened 3 years ago

chmac commented 3 years ago

Firstly, massive thanks for this library. As I start my journey into the saga wildnerness, being able to trust the types I get back is a HUGE win. Really appreciate this library.

I'm also using redux-saga-promise-actions so that I can await sagas from within other sagas. In my adventures there, I've started to suspect that the type definitions for put and putResolve should be different, but they appear to be the same.

https://github.com/agiledigital/typed-redux-saga/blob/bc524857403989fc518e00e5d369f899fd58594e/types/index.d.ts#L175-L185

In VSCode when I try const result = yield* putResolve(action()) I get the type of result as the return type of action. The same for put() instead of putResolve(). But putResolve() should be the return type of store.dispatch(action()) I think.

I've tried playing around with the types to see if I can figure out the fix, but unfortunately I'm stumped, my TypeScript fu is insufficient to the task.

chmac commented 3 years ago

It seems like in my tests putResolve() from typed-redux-saga doesn't behave the same as putResolve() from redux-saga/effects when used like:

const result = yield* putResolve(action())

When I switch to the redux-saga putResolve() then result is populated with the correct value, otherwise its undefined. Maybe it's something else in my config that's causing the issue. I can't figure it out, figured I'd mention just in case.