piotrwitek / typesafe-actions

Typesafe utilities for "action-creators" in Redux / Flux Architecture
https://codesandbox.io/s/github/piotrwitek/typesafe-actions/tree/master/codesandbox
MIT License
2.41k stars 98 forks source link

Add toString function to action creators #98

Closed mAAdhaTTah closed 5 years ago

mAAdhaTTah commented 5 years ago

This allows people migrating from redux-actions (and using == to coerce those actions to stringst to check against action.type) to continue to do so as part of an incremental transition.


Thank you for your contribution! :thumbsup:

Please makes sure that these checkboxes are checked before submitting your PR, thank you!

Extra checklist:

For new feature:

Left out the above because my intention wasn't necessarily to introduce this as a usable API but as a js -> ts migration path.

piotrwitek commented 5 years ago

Thanks for the initial work.

For this to be merged we need to complete all the points in the new feature checklist.

Also please remember to extend this: https://github.com/piotrwitek/typesafe-actions/blob/master/src/utils.ts#L19

For tests we need:

mAAdhaTTah commented 5 years ago

Added runtime tests. Will add documentation / examples, but my original thought was not to expose it to the type system, as its intended as a migration path to TS, not something you'd rely on when using it w/ TS.

piotrwitek commented 5 years ago

Right, I agree to skip exposing it in API docs & examples for now. Please just add a comment in the code as well, saying it's redux-actions migration compatibility. I might get rid of getType interna static method in place of toString at some point as they are duplicates.

mAAdhaTTah commented 5 years ago

Ok, I think we're gtg here then.

piotrwitek commented 5 years ago

Great job! Thanks a lot for all the work 🙇