redux-toolkit: Property 'then' does not exist on type AsyncThunkAction
Hi,
Found bug after migrate to react-scripts: 5.0.0
and @reduxjs/toolkit": "1.7.0"
:
TS2339: Property 'then' does not exist on type 'AsyncThunkAction<SomeType | undefined, void, {}>'.
hook initiated properly:
export type AppDispatch = typeof store.dispatch;
export const useAppDispatch = () => useDispatch<AppDispatch>();
ps: Previous working versions:
"@reduxjs/toolkit": "^1.6.1",
"react-scripts": "4.0.3",
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (4 by maintainers)
Closing as this sounds like a setup issue.
I can’t explain exactly why you get this particular error, but you can fix it by using stricter types on your reducer.
This right here basically wipes out all known type information and says “anything can be anything”:
The
combinedReducer
already is your root reducer. There’s no need to wrap in another function. Just do this:and the error on
.then()
goes away.Sorry, real life is very stressful right now. Looking at this, I’m pretty much as irritated as you are, this should be working.
The only idea I have here is that something in the redux types might have gone wrong, but that’s a shot in the dark - @markerikson do you have any idea?
@rgbutov did you forget to push/commit? that looks like an unmodified CRA project.
Can you put together a project that actually shows this happening?