redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

infinite query matchFulfilled returns wrong type

Open Dirard opened this issue 10 months ago • 7 comments

// api
getInfinityScrollThreads: build.infiniteQuery<GetPostsResponse, Args, number>

// slice
extraReducers: (builder) => {
    builder.addMatcher(api.endpoints.getInfiniteQueryPosts.matchFulfilled, (state, action) => {
       const payload = action.payload <-- shows up as GetPostsResponse but is actually { pages: GetPostsResponse[], pageParams: number[] }
    }

@markerikson Maybe I'm doing something wrong?

Dirard avatar Feb 24 '25 08:02 Dirard

No, that's presumably an actual bug - I didn't think to update the types for the matchers there. Thanks for catching this!

markerikson avatar Feb 24 '25 16:02 markerikson

No, that's presumably an actual bug - I didn't think to update the types for the matchers there. Thanks for catching this!

same issue:

providesTags: (result: { pages: GetPostsResponse[], pageParams: number[] }) => []

Dirard avatar Feb 25 '25 12:02 Dirard

Out in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.6.1 !

markerikson avatar Mar 07 '25 20:03 markerikson

@markerikson -

Out in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.6.1 !

I've installed 2.6.1, but I still see wrong types in matchFulfilled. What could be wrong?

Image

Image

nzaytsev avatar Mar 13 '25 09:03 nzaytsev

@nzaytsev can you share a repro and show what you're expecting to see there?

markerikson avatar Mar 13 '25 20:03 markerikson

@markerikson - Unfortunatelly, the original error is in private repo. I created a new repo with the same package versions. It's strange, but at the beginning the error couldn't be reproduced. After some complications it's finally reproduced, but now I cannot identify which step caused this error to be reproduced 😄 I'm sorry for useless report, I'll give you any info if I find any regularity

Here is the repo https://github.com/nzaytsev/repro-rtk-type-error Here is fallen test https://github.com/nzaytsev/repro-rtk-type-error/actions/runs/13849833086/job/38755130320

nzaytsev avatar Mar 14 '25 04:03 nzaytsev

Hmm, very strange. I'll try to find time to look into it further.

markerikson avatar Mar 14 '25 04:03 markerikson