@@ -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,19 @@ 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+ } )
6693 it ( 'should work when passed to infiniteQuery' , async ( ) => {
6794 const options = infiniteQueryOptions ( {
6895 queryKey : [ 'key' ] ,
@@ -125,6 +152,19 @@ describe('infiniteQueryOptions', () => {
125152
126153 expectTypeOf ( data ) . toEqualTypeOf < InfiniteData < string , number > > ( )
127154 } )
155+ it ( 'should ignore select when passed to fetchInfiniteQuery' , async ( ) => {
156+ const options = infiniteQueryOptions ( {
157+ queryKey : [ 'key' ] ,
158+ queryFn : ( ) => Promise . resolve ( 'string' ) ,
159+ getNextPageParam : ( ) => 1 ,
160+ initialPageParam : 1 ,
161+ select : ( data ) => data . pages ,
162+ } )
163+
164+ const data = await new QueryClient ( ) . fetchInfiniteQuery ( options )
165+
166+ expectTypeOf ( data ) . toEqualTypeOf < InfiniteData < string , number > > ( )
167+ } )
128168 it ( 'should tag the queryKey with the result type of the QueryFn' , ( ) => {
129169 const { queryKey : tagged } = infiniteQueryOptions ( {
130170 queryKey : queryKey ( ) ,
0 commit comments