Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript definitions to enforce that payload and/or meta properties are defined. #112

Closed
wants to merge 2 commits into from

Conversation

ryanmitts
Copy link

The issue I am having with the type definitions in this package are that the payload and meta 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 or meta property set.

With my TypeScipt compiler using the --strictNullChecks errors will be thrown when you try to access the payload or meta 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/or meta 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.

@codecov
Copy link

codecov bot commented Oct 11, 2018

Codecov Report

Merging #112 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #112   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines           3      3           
  Branches        1      1           
=====================================
  Hits            3      3

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98de5fe...dbabc94. Read the comment docs.

@JaKXz
Copy link
Contributor

JaKXz commented Nov 9, 2018

@ryanmitts thank you for the PR. I apologize for not getting back to you sooner, and now that #114 is also suggested, I would love to have a discussion there about what would be best. I do like the testing strategy that @couven92 came up with, do you think something similar would be possible here?

@ryanmitts
Copy link
Author

@JaKXz I would just use the other PR to solve this problem -- I didn't know you could override the optional properties like that.

@JaKXz
Copy link
Contributor

JaKXz commented Nov 9, 2018

@ryanmitts great, thanks!

@JaKXz JaKXz closed this Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants