-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Type errors when extraReducers _after_ reducers in createSlice #2862
Comments
Others have run into this in the wild as well: https://stackoverflow.com/questions/72420654/redux-toolkit-extrareducers-listed-after-reducers-causes-issues-ts2322-error |
Thanks for the repro and the investigation! My first thought is that we have to assume that users have all "strict"-type options turned on, so there may not be something we can actually do on our end. |
Honestly, I think that's a fair stance to take, strict is best-practices. But in recognition of that stance, it should be noted obviously in the docs. Probably on this page: https://redux-toolkit.js.org/usage/usage-with-typescript |
Found a solution: https://stackoverflow.com/a/74468642/4458849 |
In my case I was testing out RTK using a next.js example so the
Agreed. I went through the docs as I wanted to try and find out about some odd behavior happening with typings of |
@okcoker yeah, unfortunately next should generally come with a warning label. The TS team intends |
I was updating one of my old next.js v3 apps to v13, and decided to play around with RTK. Using the with-redux example sort of sets users up for some weird typing issues as mentioned here: reduxjs/redux-toolkit#2862 I found that github issue _after_ reading through all the official RTK x TS docs, and it seems it could have all been avoided with stricter typing. I'm hoping RTK can add this bit to their docs soon.
Description
Under specific conditions, detailed below, some slices are typed with a WritableDraft wrapper. All objects within that slice are also wrapped. This causes type errors in consumers that are expecting the unwrapped types of slices & slice values.
Repro
Minimal repro repo:
https://github.com/GYatesIII/rtk-extra-reducers-issues
From my testing, I identified the specific conditions for repro:
compilerOptions.strictFunctionTypes
set to falseThe text was updated successfully, but these errors were encountered: