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
Rewrite actions/modal and reducers/modal with typescript #24833
Rewrite actions/modal and reducers/modal with typescript #24833
Conversation
case TIMELINE_DELETE: | ||
return state.update('stack', (stack) => | ||
stack.filterNot( | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment |
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 don't think the extra ignore is required if you put an explanation string after the @ts-expect-error
. The error should probably be addressed though
Thanks for continuing working on this <3 I will have a look, but I would like to merge #23631 before any other TS PRs are merged. |
146cbfd
to
54a82a9
Compare
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.
Nice work on this, just a small nitpick (and I think you need to rebase it, and re-run eslint with my recent changes?)
}); | ||
}; | ||
|
||
export function modal(state = initialState, action: PayloadAction<any>) { |
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.
Can you rename it modalReducer
so its more explicit?
Also, could it be a good place to start rewriting the reducer with This specific modal state seem to only be used in If you feel confident with this, you can open another PR after this one doing it, or I can have a go as well. I would like a simple example of how a full rewrite to Typescript look like (Actions, Reducer, removing Immer, then rewriting into a FunctionComponent using Redux's hooks) |
This pull request has merge conflicts that must be resolved before it can be merged. |
OK, I will try that next week. |
b905c95
to
cf44df1
Compare
This pull request has resolved merge conflicts and is ready for review. |
cf44df1
to
911f569
Compare
rebased. I tried rewriting this reducer with createReducer. It is difficult for me, and I seem that is too big to include this PR. |
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.
Looks good to me, except the modalReducer
renaming in the state, it should be kept as key
.
I missed that this was using async thunks, I will have a look later on the best way to handle this.
I think we could also have OpenModalPayload
as a generic type, which would allow to properly type modalProps
, I will try to find a way to make it work once this PR is merged.
Thanks again for this, good work!
@@ -50,7 +50,7 @@ const reducers = { | |||
meta, | |||
alerts, | |||
loadingBar: loadingBarReducer, | |||
modal, | |||
modalReducer, |
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.
You should not change the key here, but use modal: modalReducer
.
This would avoid changing the modal
key everywhere this is accessed
911f569
to
a8f9523
Compare
This pull request has merge conflicts that must be resolved before it can be merged. |
1d45331
to
def9a79
Compare
This pull request has resolved merge conflicts and is ready for review. |
This pull request has merge conflicts that must be resolved before it can be merged. |
def9a79
to
8fc0b2e
Compare
This pull request has resolved merge conflicts and is ready for review. |
rebased! |
This PR rewrites actions/modal and reducers/modal with typescript and createAction.