@@ -35,6 +35,7 @@ import type {
3535 OmitFromUnion ,
3636 UnwrapPromise ,
3737} from './tsHelpers'
38+ import { AnyARecord } from 'dns'
3839
3940const resultType = /* @__PURE__ */ Symbol ( )
4041const baseQuery = /* @__PURE__ */ Symbol ( )
@@ -43,6 +44,7 @@ type EndpointDefinitionWithQuery<
4344 QueryArg ,
4445 BaseQuery extends BaseQueryFn ,
4546 ResultType ,
47+ PageParam = never ,
4648> = {
4749 /**
4850 * `query` can be a function that returns either a `string` or an `object` which is passed to your `baseQuery`. If you are using [fetchBaseQuery](./fetchBaseQuery), this can return either a `string` or an `object` of properties in `FetchArgs`. If you use your own custom [`baseQuery`](../../rtk-query/usage/customizing-queries), you can customize this behavior to your liking.
@@ -546,6 +548,7 @@ export type QueryDefinition<
546548// cloning Query Endpoint Definition with an extra option to begin with
547549export interface InfiniteQueryTypes <
548550 QueryArg ,
551+ PageParam ,
549552 BaseQuery extends BaseQueryFn ,
550553 TagTypes extends string ,
551554 ResultType ,
@@ -560,6 +563,7 @@ export interface InfiniteQueryTypes<
560563 */
561564 InfiniteQueryDefinition : InfiniteQueryDefinition <
562565 QueryArg ,
566+ PageParam ,
563567 BaseQuery ,
564568 TagTypes ,
565569 ResultType ,
@@ -573,6 +577,7 @@ export interface InfiniteQueryExtraOptions<
573577 TagTypes extends string ,
574578 ResultType ,
575579 QueryArg ,
580+ PageParam ,
576581 BaseQuery extends BaseQueryFn ,
577582 ReducerPath extends string = string ,
578583> extends CacheLifecycleInfiniteQueryExtraOptions <
@@ -664,6 +669,7 @@ export interface InfiniteQueryExtraOptions<
664669 */
665670 Types ?: InfiniteQueryTypes <
666671 QueryArg ,
672+ PageParam ,
667673 BaseQuery ,
668674 TagTypes ,
669675 ResultType ,
@@ -673,18 +679,22 @@ export interface InfiniteQueryExtraOptions<
673679
674680export type InfiniteQueryDefinition <
675681 QueryArg ,
682+ PageParam ,
676683 BaseQuery extends BaseQueryFn ,
677684 TagTypes extends string ,
678685 ResultType ,
679686 ReducerPath extends string = string ,
680- > = BaseEndpointDefinition < QueryArg , BaseQuery , ResultType > &
681- InfiniteQueryExtraOptions <
682- TagTypes ,
683- ResultType ,
684- QueryArg ,
685- BaseQuery ,
686- ReducerPath
687- >
687+ > =
688+ // Intentionally use `PageParam` as the QueryArg` type
689+ BaseEndpointDefinition < PageParam , BaseQuery , ResultType > &
690+ InfiniteQueryExtraOptions <
691+ TagTypes ,
692+ ResultType ,
693+ QueryArg ,
694+ PageParam ,
695+ BaseQuery ,
696+ ReducerPath
697+ >
688698
689699type MutationTypes <
690700 QueryArg ,
@@ -812,11 +822,13 @@ export type EndpointDefinition<
812822 TagTypes extends string ,
813823 ResultType ,
814824 ReducerPath extends string = string ,
825+ PageParam = any ,
815826> =
816827 | QueryDefinition < QueryArg , BaseQuery , TagTypes , ResultType , ReducerPath >
817828 | MutationDefinition < QueryArg , BaseQuery , TagTypes , ResultType , ReducerPath >
818829 | InfiniteQueryDefinition <
819830 QueryArg ,
831+ PageParam ,
820832 BaseQuery ,
821833 TagTypes ,
822834 ResultType ,
@@ -842,7 +854,7 @@ export function isMutationDefinition(
842854
843855export function isInfiniteQueryDefinition (
844856 e : EndpointDefinition < any , any , any , any > ,
845- ) : e is InfiniteQueryDefinition < any , any , any , any > {
857+ ) : e is InfiniteQueryDefinition < any , any , any , any , any > {
846858 return e . type === DefinitionType . infinitequery
847859}
848860
@@ -922,10 +934,11 @@ export type EndpointBuilder<
922934 > ,
923935 ) : MutationDefinition < QueryArg , BaseQuery , TagTypes , ResultType , ReducerPath >
924936
925- infiniteQuery < ResultType , QueryArg > (
937+ infiniteQuery < ResultType , QueryArg , PageParam > (
926938 definition : OmitFromUnion <
927939 InfiniteQueryDefinition <
928940 QueryArg ,
941+ PageParam ,
929942 BaseQuery ,
930943 TagTypes ,
931944 ResultType ,
@@ -935,6 +948,7 @@ export type EndpointBuilder<
935948 > ,
936949 ) : InfiniteQueryDefinition <
937950 QueryArg ,
951+ PageParam ,
938952 BaseQuery ,
939953 TagTypes ,
940954 ResultType ,
@@ -981,7 +995,15 @@ export function expandTagDescription(
981995}
982996
983997export type QueryArgFrom < D extends BaseEndpointDefinition < any , any , any > > =
984- D extends BaseEndpointDefinition < infer QA , any , any > ? QA : unknown
998+ D extends BaseEndpointDefinition < infer QA , any , any > ? QA : never
999+
1000+ // Just extracting `QueryArg` from `BaseEndpointDefinition`
1001+ // doesn't sufficiently match here.
1002+ // We need to explicitly match against `InfiniteQueryDefinition`
1003+ export type InfiniteQueryArgFrom <
1004+ D extends BaseEndpointDefinition < any , any , any > ,
1005+ > = D extends InfiniteQueryDefinition < infer QA , any , any , any , any > ? QA : never
1006+
9851007export type ResultTypeFrom < D extends BaseEndpointDefinition < any , any , any > > =
9861008 D extends BaseEndpointDefinition < any , any , infer RT > ? RT : unknown
9871009
@@ -992,6 +1014,11 @@ export type ReducerPathFrom<
9921014export type TagTypesFrom < D extends EndpointDefinition < any , any , any , any > > =
9931015 D extends EndpointDefinition < any , any , infer RP , any > ? RP : unknown
9941016
1017+ export type PageParamFrom <
1018+ D extends InfiniteQueryDefinition < any , any , any , any , any > ,
1019+ > =
1020+ D extends InfiniteQueryDefinition < any , infer PP , any , any , any > ? PP : unknown
1021+
9951022export type TagTypesFromApi < T > =
9961023 T extends Api < any , any , any , infer TagTypes > ? TagTypes : never
9971024
@@ -1035,13 +1062,15 @@ export type OverrideResultType<Definition, NewResultType> =
10351062 >
10361063 : Definition extends InfiniteQueryDefinition <
10371064 infer QueryArg ,
1065+ infer PageParam ,
10381066 infer BaseQuery ,
10391067 infer TagTypes ,
10401068 any ,
10411069 infer ReducerPath
10421070 >
10431071 ? InfiniteQueryDefinition <
10441072 QueryArg ,
1073+ PageParam ,
10451074 BaseQuery ,
10461075 TagTypes ,
10471076 NewResultType ,
@@ -1084,13 +1113,15 @@ export type UpdateDefinitions<
10841113 >
10851114 : Definitions [ K ] extends InfiniteQueryDefinition <
10861115 infer QueryArg ,
1116+ infer PageParam ,
10871117 infer BaseQuery ,
10881118 any ,
10891119 infer ResultType ,
10901120 infer ReducerPath
10911121 >
10921122 ? InfiniteQueryDefinition <
10931123 QueryArg ,
1124+ PageParam ,
10941125 BaseQuery ,
10951126 NewTagTypes ,
10961127 TransformedResponse < NewDefinitions , K , ResultType > ,
0 commit comments