Skip to content

Commit 038c8a3

Browse files
committed
Make page param callback types consistent
1 parent 092946e commit 038c8a3

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

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

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,31 @@ export type RefetchConfigOptions = {
3030
refetchOnFocus: boolean
3131
}
3232

33-
export type GetNextPageParamFunction<TPageParam, TQueryFnData> = (
34-
lastPage: TQueryFnData,
35-
allPages: Array<TQueryFnData>,
36-
lastPageParam: TPageParam,
37-
allPageParams: Array<TPageParam>,
38-
) => TPageParam | undefined | null
33+
export type PageParamFunction<DataType, PageParam> = (
34+
firstPage: DataType,
35+
allPages: Array<DataType>,
36+
firstPageParam: PageParam,
37+
allPageParams: Array<PageParam>,
38+
) => PageParam | undefined | null
3939

40-
export type GetPreviousPageParamFunction<TPageParam, TQueryFnData> = (
41-
firstPage: TQueryFnData,
42-
allPages: Array<TQueryFnData>,
43-
firstPageParam: TPageParam,
44-
allPageParams: Array<TPageParam>,
45-
) => TPageParam | undefined | null
46-
47-
export type InfiniteQueryConfigOptions<TQueryFnData, TPageParam> = {
48-
initialPageParam: TPageParam
40+
export type InfiniteQueryConfigOptions<DataType, PageParam> = {
41+
initialPageParam: PageParam
4942
maxPages?: number
5043
/**
5144
* This function can be set to automatically get the previous cursor for infinite queries.
5245
* The result will also be used to determine the value of `hasPreviousPage`.
5346
*/
54-
getPreviousPageParam?: GetPreviousPageParamFunction<TPageParam, TQueryFnData>
55-
getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>
47+
getPreviousPageParam?: PageParamFunction<DataType, PageParam>
48+
/**
49+
* This function is required to automatically get the next cursor for infinite queries.
50+
* The result will also be used to determine the value of `hasNextPage`.
51+
*/
52+
getNextPageParam: PageParamFunction<DataType, PageParam>
5653
}
5754

58-
export interface InfiniteData<TData, TPageParam> {
59-
pages: Array<TData>
60-
pageParams: Array<TPageParam>
55+
export interface InfiniteData<DataType, PageParam> {
56+
pages: Array<DataType>
57+
pageParams: Array<PageParam>
6158
}
6259

6360
/**

packages/toolkit/src/query/tests/infiniteQueries.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,12 +657,10 @@ describe('Infinite queries', () => {
657657
},
658658
async onCacheEntryAdded(arg, api) {
659659
const data = await api.cacheDataLoaded
660-
console.log('onCacheEntryAdded data: ', arg, data)
661660
cacheEntryAddedCallback(arg, data)
662661
},
663662
async onQueryStarted(arg, api) {
664663
const data = await api.queryFulfilled
665-
console.log('onQueryStarted data: ', arg, data)
666664
queryStartedCallback(arg, data)
667665
},
668666
}),

0 commit comments

Comments
 (0)