-
-
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 'Data' is not assignable to type 'WritableDraft<Data>' After UI Library Update #4900
Comments
this tends to come up in one of two ways:
either way, the easiest way to get around this is to use immer's state.filter = castDraft(payload); |
I tried it, and it worked successfully without any errors. Now, I will need to refactor all slice files like this. My main concern is why this problem occurred after I updated the UI library, even though there wasn't such an issue before. The UI library includes a |
rollup shouldn't affect your typescript experience, and if you're getting them in all slice files there might be something else going on. Make sure you only have one copy of |
I checked the project, and there were no major changes in the Immer versions. I tried a few different versions, but I still couldn’t resolve the errors. It seems like there’s only one copy of Immer in the project. I wanted to remove the Immer library from the project, but I couldn’t because the I managed to fix the type errors in about 20 slice files using type assertions and Additionally, I thoroughly checked the versions of each library in the repositories to ensure compatibility, but I still couldn’t pinpoint the exact cause of the issue. |
the opposite of castDraft is castImmutable |
Description:
Hi,
I am facing an issue with Redux Toolkit (v1.8.1) and TypeScript after updating a UI library in my project as a minor version update. After the update, I started receiving the following TypeScript error across all slice files:
Steps to Reproduce:
Environment:
Possible Cause:
The error appears after updating the UI library, which may have caused a type mismatch between
Data
andWritableDraft<Data>
. The error message specifically mentions an issue with thefilters
property, where aData2[]
type is being assigned to aWritableDraft<Data2>[]
.I also believe that the Rollup configuration in the UI library may be affecting my project. Since the update, I am experiencing this issue in all my slice files where I use Redux Toolkit. Despite having no issues before the update, now every slice file that uses Redux Toolkit and Immer is throwing the same TypeScript error.
Expected Behavior:
There should be no type compatibility issue, and the code should compile without errors after the UI library update.
What I Have Tried:
Additional Information:
What I Am Asking For:
I would appreciate any guidance or solutions to resolve this TypeScript type compatibility issue, especially with respect to how Rollup configuration could be influencing Redux Toolkit's behavior in my project. If this is a known issue with Redux Toolkit or Rollup, any suggestions on how to fix or workaround this problem would be helpful.
Thank you!
The text was updated successfully, but these errors were encountered: