Add TypeScript definitions to enforce that payload
and/or meta
properties are defined.
#112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue I am having with the type definitions in this package are that the
payload
andmeta
properties on actions are marked optional.When I define my own actions and extend the types using this package -- I know that some of my actions will and must always have a
payload
ormeta
property set.With my TypeScipt compiler using the
--strictNullChecks
errors will be thrown when you try to access thepayload
ormeta
values as they could be undefined given the current definition of an FSA.The work around would be to always do an
if
check to see if the properties are defined.This is not very nice in your code.
I have proposed new definitions where you can specify and an FSA has a
payload
and/ormeta
property.This has been documented in issue #109 .
This also fixes a small bug with the newer minor versions of Jest as documented in the commit message for that fix.