Skip to content

TypeScript error when using RTK Matcher function with listenerMiddleware #4582

Answered by markerikson
moloko asked this question in Q&A
Discussion options

You must be logged in to vote

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 the effect in another file here?

You might want to consider using the "setu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@moloko
Comment options

Answer selected by moloko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants