@@ -51,6 +51,20 @@ describe('infiniteQueryOptions', () => {
5151 InfiniteData < string , unknown > | undefined
5252 > ( )
5353 } )
54+ it ( 'should work when passed to useInfiniteQuery with select' , ( ) => {
55+ const options = infiniteQueryOptions ( {
56+ queryKey : [ 'key' ] ,
57+ queryFn : ( ) => Promise . resolve ( 'string' ) ,
58+ getNextPageParam : ( ) => 1 ,
59+ initialPageParam : 1 ,
60+ select : ( data ) => data . pages ,
61+ } )
62+
63+ const { data } = useInfiniteQuery ( options )
64+
65+ // known issue: type of pageParams is unknown when returned from useInfiniteQuery
66+ expectTypeOf ( data ) . toEqualTypeOf < Array < string > | undefined > ( )
67+ } )
5468 it ( 'should work when passed to useSuspenseInfiniteQuery' , ( ) => {
5569 const options = infiniteQueryOptions ( {
5670 queryKey : queryKey ( ) ,
@@ -63,6 +77,44 @@ describe('infiniteQueryOptions', () => {
6377
6478 expectTypeOf ( data ) . toEqualTypeOf < InfiniteData < string , unknown > > ( )
6579 } )
80+ it ( 'should work when passed to useSuspenseInfiniteQuery with select' , ( ) => {
81+ const options = infiniteQueryOptions ( {
82+ queryKey : [ 'key' ] ,
83+ queryFn : ( ) => Promise . resolve ( 'string' ) ,
84+ getNextPageParam : ( ) => 1 ,
85+ initialPageParam : 1 ,
86+ select : ( data ) => data . pages ,
87+ } )
88+
89+ const { data } = useSuspenseInfiniteQuery ( options )
90+
91+ expectTypeOf ( data ) . toEqualTypeOf < Array < string > > ( )
92+ } )
93+ it ( 'should work when passed to infiniteQuery' , async ( ) => {
94+ const options = infiniteQueryOptions ( {
95+ queryKey : [ 'key' ] ,
96+ queryFn : ( ) => Promise . resolve ( 'string' ) ,
97+ getNextPageParam : ( ) => 1 ,
98+ initialPageParam : 1 ,
99+ } )
100+
101+ const data = await new QueryClient ( ) . infiniteQuery ( options )
102+
103+ expectTypeOf ( data ) . toEqualTypeOf < InfiniteData < string , number > > ( )
104+ } )
105+ it ( 'should work when passed to infiniteQuery with select' , async ( ) => {
106+ const options = infiniteQueryOptions ( {
107+ queryKey : [ 'key' ] ,
108+ queryFn : ( ) => Promise . resolve ( 'string' ) ,
109+ getNextPageParam : ( ) => 1 ,
110+ initialPageParam : 1 ,
111+ select : ( data ) => data . pages ,
112+ } )
113+
114+ const data = await new QueryClient ( ) . infiniteQuery ( options )
115+
116+ expectTypeOf ( data ) . toEqualTypeOf < Array < string > > ( )
117+ } )
66118 it ( 'should work when passed to fetchInfiniteQuery' , async ( ) => {
67119 const options = infiniteQueryOptions ( {
68120 queryKey : queryKey ( ) ,
@@ -75,6 +127,19 @@ describe('infiniteQueryOptions', () => {
75127
76128 expectTypeOf ( data ) . toEqualTypeOf < InfiniteData < string , number > > ( )
77129 } )
130+ it ( 'should ignore select when passed to fetchInfiniteQuery' , async ( ) => {
131+ const options = infiniteQueryOptions ( {
132+ queryKey : [ 'key' ] ,
133+ queryFn : ( ) => Promise . resolve ( 'string' ) ,
134+ getNextPageParam : ( ) => 1 ,
135+ initialPageParam : 1 ,
136+ select : ( data ) => data . pages ,
137+ } )
138+
139+ const data = await new QueryClient ( ) . fetchInfiniteQuery ( options )
140+
141+ expectTypeOf ( data ) . toEqualTypeOf < InfiniteData < string , number > > ( )
142+ } )
78143 it ( 'should tag the queryKey with the result type of the QueryFn' , ( ) => {
79144 const { queryKey : tagged } = infiniteQueryOptions ( {
80145 queryKey : queryKey ( ) ,
0 commit comments