Skip to content

Commit

Permalink
Force selector type for infinite query test
Browse files Browse the repository at this point in the history
  • Loading branch information
riqts committed May 5, 2024
1 parent 758c132 commit 21d642f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/toolkit/src/query/core/apiState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,11 @@ export type QuerySubState<D extends BaseEndpointDefinition<any, any, any>> = Id<
>

export type InfiniteQuerySubState<D extends BaseEndpointDefinition<any, any, any>> = QuerySubState<D> & {
hasNextPage: boolean
hasPreviousPage: boolean
isFetchingNextPage: boolean
isFetchingPreviousPage: boolean
// TODO: These shouldn't be optional
hasNextPage?: boolean
hasPreviousPage?: boolean
isFetchingNextPage?: boolean
isFetchingPreviousPage?: boolean
param?: QueryArgFrom<D>
direction?: 'forward' | 'backwards'
}
Expand Down
1 change: 1 addition & 0 deletions packages/toolkit/src/query/core/buildInitiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export function buildInitiate({
})
return runningQueries.get(dispatch)?.[queryCacheKey] as
| QueryActionCreatorResult<never>
| InfiniteQueryActionCreatorResult<never>
| undefined
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/core/buildSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function buildSelectors<
queryArgs === skipToken ? selectSkippedQuery : selectQuerySubstate

return createSelector(finalSelectQuerySubState, withRequestFlags)
}) as QueryResultSelectorFactory<any, RootState>
}) as InfiniteQueryResultSelectorFactory<any, RootState>
}

function buildMutationSelector() {
Expand Down
5 changes: 4 additions & 1 deletion packages/toolkit/src/query/core/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { buildSelectors } from './buildSelectors'
import type {
MutationActionCreatorResult,
QueryActionCreatorResult,
InfiniteQueryActionCreatorResult
} from './buildInitiate'
import { buildInitiate } from './buildInitiate'
import { assertCast, safeAssign } from '../tsHelpers'
Expand Down Expand Up @@ -159,6 +160,7 @@ declare module '../apiTypes' {
| QueryActionCreatorResult<
Definitions[EndpointName] & { type: 'query' }
>
| InfiniteQueryActionCreatorResult<Definitions[EndpointName] & {type: 'infinitequery'}>
| undefined
>

Expand Down Expand Up @@ -191,7 +193,7 @@ declare module '../apiTypes' {
* See https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering for details.
*/
getRunningQueriesThunk(): ThunkWithReturnValue<
Array<QueryActionCreatorResult<any>>
Array<QueryActionCreatorResult<any> | InfiniteQueryActionCreatorResult<any>>
>

/**
Expand Down Expand Up @@ -561,6 +563,7 @@ export const coreModule = ({
context,
queryThunk,
mutationThunk,
infiniteQueryThunk,
api,
assertTagType,
})
Expand Down

0 comments on commit 21d642f

Please sign in to comment.