omnidan / redux-undo

:recycle: higher order reducer to add undo/redo functionality to redux state containers
MIT License
2.91k stars 188 forks source link

Add stronger type enforcements #265

Closed kxlow closed 4 years ago

kxlow commented 4 years ago

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

TypeScript definition update

What is the current behavior? (You can also link to an open issue here)

You can provide any string into a filter function, even if it not a valid action for the given reducer.

What is the new behavior?

When using TypeScript, TypeScript will display an error when you are giving filter functions an invalid action. image

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

It shouldn't, if I did my types correctly.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 97.674% when pulling c671e7abefa29777ca855ad6452e8119b36bdc98 on kxlow:stronger-types into c66aaa25363dd35bb92df193914137cc338de73a on omnidan:master.

kxlow commented 4 years ago

And on line 84, you can just use A['type'] instead of Pick<A, 'type'>['type']

🤦‍♂ Thanks!

nmay231 commented 4 years ago

Looks good to me.

@omnidan ?

omnidan commented 4 years ago

@nmay231 looks good to me as well!

nmay231 commented 4 years ago

Thanks @kxlow !

kxlow commented 4 years ago

Thanks for all your help and for maintaining this project! :)

kxlow commented 4 years ago

Will there be a published release of including these changes? I'd like to use this in my project. 😅

nmay231 commented 4 years ago

Yes, as soon as @ omnidan is able, he will publish those changes. Life is busy atm.

If you want to still use those typings now, you can remove then reinstall redux-undo from the cloned folder with npm i "path/to/local/folder/redux-undo". Or you can temporarily install directly from github adding this to package.json "redux-undo": "omnidan/redux-undo#master"

We'll try to get the official version out soon though.

omnidan commented 4 years ago

@kxlow @nmay231 sorry for the delay! I have published a new version 1.0.1 of redux-undo with the stronger type enforcements. Let me know if everything works fine for you now. Thanks for the PR!