-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
[WIP] Polymorphic Flow Types #356
Conversation
switch (action.type) { | ||
case INCREMENT_COUNTER: | ||
case 'INCREMENT_COUNTER': | ||
return state + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will returning non-number fail the type check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes!
This is really really good so far! Thanks for working on it. The next (in terms of importance) after |
@gaearon yes, been trying to think how to type those in a polymorphic way. Will push updates into this PR |
💃 👯 Would love types! Thanks for working on this. |
Closing, so I can delete |
Adding Flow types again, this time polymorphic so that we can define custom action types in the apps and make them type check correctly when using them with redux. Addresses #290
So far this only has the
createStore
typed, will work on the other util functions. Just wanted to show the progress so far and if anyone wants to chime in and give feedback, more than welcome!I have a temporary file in the counter example that is the actual one being type checked, instead of the real entry point (since I haven't yet typed the other util functions), which is
sample.js
. If you want to play around, uncommenting the lines there and runningflow
will correctly show the type errors.You may need to change the counter's
package.json
dependencies to makeredux
point tofile:../../
so that it grabs the code from the real source instead of npm (which doesn't have flow types yet).Caveat so far: There is a bug in Flow (facebook/flow#582) which forces us to explicitly specify the init action type inside the union list of the app's action types. Until that gets fixed, I'm afraid we'll need to keep doing that instead of having that type provided by
redux
itself, which is defined in theflow/types.js
file but not used.