dphilipson / typescript-fsa-reducers

Fluent syntax for defining typesafe reducers on top of typescript-fsa.
MIT License
220 stars 16 forks source link

Cannot pass undefined as state to reducer #21

Closed amc6 closed 6 years ago

amc6 commented 6 years ago

The type signature of ReducerBuilder does not allow undefined to be passed as the state, even though this should be allowed and is in fact allowed at runtime. The workaround seems to be to pass undefined like so: reducer(undefined as any, action). But that's a little ugly especially if you have configured tslint to forbid any.

I believe its a pretty easy change to fix this, and will submit a pull request soon.

dphilipson commented 6 years ago

You're absolutely right. I was basing my definition of Reducer off the one in the Redux typings, which used to have the same problem. Looks like the latest version of Redux typings marks the state as optional, so this change is a good one. I'll accept the PR and cut a new release.

Thank you very much for the contribution!

dphilipson commented 6 years ago

Fix is contained in v0.4.5. Thanks again!