-
Notifications
You must be signed in to change notification settings - Fork 60
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 Luau types for actions and reducers #70
Add Luau types for actions and reducers #70
Conversation
- name: code quality (stylua) | ||
shell: bash | ||
run: | | ||
stylua -c src/ |
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.
We ought to be running Selene ahead of darklua as well. We may even consider splitting it out into a separate quality CI job that runs selene/stylua/whatever analysis we can support, and one that runs darklua/tests/coverage reporting
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.
I reached out to the Selene maintainer and they graciously cut a release pretty quickly (thank you Kampfkarren!!) that supports my usage of generic type packs, so both checks are now running ahead of darklua. Let me know if you want me to move around the CI jobs any more than I already have.
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
I have read the CLA Document and I hereby sign the CLA |
src/combineReducers.lua
Outdated
|
||
local function combineReducers<State>(map): Reducer<State> | ||
return ( | ||
function(state, action) |
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.
maybe something like this and eliminate the hard cast?
function(state, action) | |
function<S>(state: S?, action: AnyAction): S |
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.
I tried a few things, but I settled on the any cast. I think this needs better generic type constraint support on the Luau side, otherwise you end up with some "unable to convert to State" errors, even when using the pseudo-constraint trick you showed me.
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.
Great work, this looks good! We'll need to be careful around how we cut the next version, since it'll break for folks who are running it in non-luau environments like lua 5.1 ci jobs
Follows up on the types added in: #70. Adds Luau types for thunks and the store. This is partially inspired by upstream Redux types here and here, but modified to be as useful as possible given Luau's constraints.
Adds Luau types for actions and reducers, directly inspired by upstream Redux types.