-
-
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 error: The inferred type of 'configureStore' cannot be named without a reference to '@reduxjs/toolkit/node_modules/redux'. This is likely not portable. A type annotation is necessary.
#3962
Comments
This is likely related to your TS config settings. Can you post your entire |
|
Also seeing this issue after upgrading to both |
I just upgraded to the latest versions, and get a complaints for references to
If i
Note that if I just use the default middleware (not my additional middleware) the error is still there. UPDATE: I found another use of I'm getting other errors, though, in RTK Query #3983 |
My issue is if the same nature but due to redux type collision. Yarn hoisting is the culprit and we are using redux-logger. Removing redux-logger solves the issue. yarn nohoist config did not help, but I suspect using pnpm that doesn't hoist will work. For everyone encointering the issue doing |
After I upgraded from
|
Any updates on this error? |
https://typescript.tv/errors/#ts2742 |
We are also running into this error, and deeps specifically due to However, we are unable to disable this config as we create a package out of our redux store and wish to have types generated from it. Both Installing In the previous versions of RTK we had a similar problem with actions
Caused by
Simply spreading the actions "fixed' it .
This feels similar, but no such workarounds existed for the errors with store. Because we are unable to find workarounds for this (and trying to annotate with |
Making this a separate comment so any interested parties will be notified of this. I discovered that simply importing all types will fix most of these errors. The only one it won't fix is the import type * as rtk from "@reduxjs/toolkit"; Including this in any file which gives you |
I recently ran into this problem as well, any updates on the issue? The solution provided by @chrishoage worked for me, but is it the correct solution? I'm developing a npm package and did follow the official documentation for nextjs / typescript and ran into this problem. |
We ended up aborting our upgrade because the work-round I highlighted above didn't work in some cases. Ultimately some types were not exported and typescript couldn't reconcile this. I did notice that Typescript 5.5 mentions this error in particular in an upcoming release. I have not tested to see if it helps this situation at all |
Sorry we haven't had time to look at this. Can folks post some full repo projects that show this happening? |
Sorry, I'm not able to publish the repo since it's a company repo where this issue occours. Let me know if it would help if I could upload something else, like ts config or what else. But the issue occurs for every file which exports any kind of function that has types tied to redux toolkit for me. The error is only shown att compile time, I'm using tsc to compile the package |
Hi, please let me provide a humble example of such use case: Thank you for your time! |
@ryuujo1573 Thanks for the repro, I'm gonna take a look, |
- This should serve as a partial fix for reduxjs#3962, reduxjs#4448, reduxjs#3983, reduxjs#4066, reduxjs#4108, reduxjs#4401 - Here is the list of the problematic (now exported) types: From `@reduxjs/toolkit`: - `CombinedSliceReducer` - `CaseReducerDefinition` - `Id` renamed to `TSHelpersId` - `UncheckedIndexedAccess` - `ReducerWithInitialState` - `CaseReducerDefinition` - `Id` renamed to `TSHelpersId` - `UncheckedIndexedAccess` - `ReducerWithInitialState` From `@reduxjs/toolkit/query/react`: - `UseLazyQuery` - `UseQuery` - `QueryHooks`
If anybody else has any examples of this please let me know, it doesn't have to be a repro, a code snippet should be fine. |
Hope it helps. Seems pretty basic to me: Seems to be related to AsyncThunkConfig. Cause when i try to type manually: I cant import AsyncThunkConfig
@reduxjs/toolkit: "^2.2.6"
getting:
would appreciate a fast fix :) |
Can you run this command and try again to see if it fixes the issue: npm install https://pkg.csb.dev/reduxjs/redux-toolkit/commit/28afb060/@reduxjs/toolkit |
Hey @aryaemami59, Yeah rolled back to the commit from 3 days ago and it went away for createAsyncThunk and also for configureStore. Hopefully this results in an PR fast :) |
Hello, I cannot provide a repo for the reproduction due to corporate. But I was facing this error including some others. Downgrading my TS version from 5.5.3 -> 5.4.5 got rid of the errors for me. |
Not sure if its the right solution, but the error is gone when i set a type to the "store" variable. Example: Error when:
Solution:
|
@georgeiliadis91 Can you at least share the code snippet that is causing the error? I just need to have a general idea of what function is being called and what types are being used. @dasler-fw I would highly advise against doing that as it overrides all the type inference provided by TypeScript. Instead can you try running this in your CLI and see if it fixes the issue: npm install https://pkg.csb.dev/reduxjs/redux-toolkit/commit/28afb060/@reduxjs/toolkit |
"@reduxjs/toolkit": "^2.0.1",
eror:The text was updated successfully, but these errors were encountered: