Skip to content

Commit 03833a4

Browse files
riqtsmarkerikson
authored andcommitted
Force selector type for infinite query test
1 parent b3c35bd commit 03833a4

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

packages/toolkit/src/query/core/apiState.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,11 @@ export type QuerySubState<D extends BaseEndpointDefinition<any, any, any>> = Id<
229229
>
230230

231231
export type InfiniteQuerySubState<D extends BaseEndpointDefinition<any, any, any>> = QuerySubState<D> & {
232-
hasNextPage: boolean
233-
hasPreviousPage: boolean
234-
isFetchingNextPage: boolean
235-
isFetchingPreviousPage: boolean
232+
// TODO: These shouldn't be optional
233+
hasNextPage?: boolean
234+
hasPreviousPage?: boolean
235+
isFetchingNextPage?: boolean
236+
isFetchingPreviousPage?: boolean
236237
param?: QueryArgFrom<D>
237238
direction?: 'forward' | 'backwards'
238239
}

packages/toolkit/src/query/core/buildInitiate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ export function buildInitiate({
301301
})
302302
return runningQueries.get(dispatch)?.[queryCacheKey] as
303303
| QueryActionCreatorResult<never>
304+
| InfiniteQueryActionCreatorResult<never>
304305
| undefined
305306
}
306307
}

packages/toolkit/src/query/core/buildSelectors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export function buildSelectors<
230230
queryArgs === skipToken ? selectSkippedQuery : selectQuerySubstate
231231

232232
return createSelector(finalSelectQuerySubState, withRequestFlags)
233-
}) as QueryResultSelectorFactory<any, RootState>
233+
}) as InfiniteQueryResultSelectorFactory<any, RootState>
234234
}
235235

236236
function buildMutationSelector() {

packages/toolkit/src/query/core/module.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import type {
3939
BuildInitiateApiEndpointQuery,
4040
MutationActionCreatorResult,
4141
QueryActionCreatorResult,
42+
InfiniteQueryActionCreatorResult,
4243
} from './buildInitiate'
4344
import { buildInitiate } from './buildInitiate'
4445
import type {
@@ -170,6 +171,9 @@ export interface ApiModules<
170171
| QueryActionCreatorResult<
171172
Definitions[EndpointName] & { type: 'query' }
172173
>
174+
| InfiniteQueryActionCreatorResult<
175+
Definitions[EndpointName] & { type: 'infinitequery' }
176+
>
173177
| undefined
174178
>
175179

@@ -202,7 +206,9 @@ export interface ApiModules<
202206
* See https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering for details.
203207
*/
204208
getRunningQueriesThunk(): ThunkWithReturnValue<
205-
Array<QueryActionCreatorResult<any>>
209+
Array<
210+
QueryActionCreatorResult<any> | InfiniteQueryActionCreatorResult<any>
211+
>
206212
>
207213

208214
/**
@@ -581,6 +587,7 @@ export const coreModule = ({
581587
context,
582588
queryThunk,
583589
mutationThunk,
590+
infiniteQueryThunk,
584591
api,
585592
assertTagType,
586593
})

0 commit comments

Comments
 (0)