TypeScript error when using RTK Matcher function with listenerMiddleware #4582
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
We've found that the RTK types sometimes have issues when you do a function call on the right side of an object field, like Try moving that to a separate variable, like Also, while it's not directly related, note that we designed the listener middleware API with the assumption that you'd write the You might want to consider using the "setup function in slice" organization approach shown here: |
Beta Was this translation helpful? Give feedback.
We've found that the RTK types sometimes have issues when you do a function call on the right side of an object field, like
configureStore({reducer: createRootReducer()})
, or in this case,matcher: isAnyOf()
.Try moving that to a separate variable, like
const isElementAction = isAnyOf(setElementSTarted, setElementCompleted)
, and see if it fixes the issue.Also, while it's not directly related, note that we designed the listener middleware API with the assumption that you'd write the
effect
functions inline to get the proper TS type inference, rather than defining them separately - any particular reason you defined theeffect
in another file here?You might want to consider using the "setu…