@@ -153,7 +153,7 @@ describe('queryOptions', () => {
153153 queryClient . prefetchQuery ( options )
154154 } )
155155
156- test ( 'allow optional initialData' , ( ) => {
156+ test ( 'allow optional initialData function ' , ( ) => {
157157 const initialData : { example : boolean } | undefined = { example : true }
158158 const queryOptions = infiniteQueryOptions ( {
159159 queryKey : [ 'example' ] ,
@@ -168,6 +168,27 @@ describe('queryOptions', () => {
168168 queryOptions . initialData
169169 expectTypeOf ( queryOptions . initialData ) . toMatchTypeOf <
170170 | InitialDataFunction < InfiniteData < { example : boolean } , number > >
171+ | InfiniteData < { example : boolean } , number >
172+ | undefined
173+ > ( )
174+ } )
175+
176+ test ( 'allow optional initialData object' , ( ) => {
177+ const initialData : { example : boolean } | undefined = { example : true }
178+ const queryOptions = infiniteQueryOptions ( {
179+ queryKey : [ 'example' ] ,
180+ queryFn : async ( ) => initialData ,
181+ // initialData below errors
182+ initialData : initialData
183+ ? { pages : [ initialData ] , pageParams : [ ] }
184+ : undefined ,
185+ getNextPageParam : ( ) => 1 ,
186+ initialPageParam : 1 ,
187+ } )
188+ queryOptions . initialData
189+ expectTypeOf ( queryOptions . initialData ) . toMatchTypeOf <
190+ | InitialDataFunction < InfiniteData < { example : boolean } , number > >
191+ | InfiniteData < { example : boolean } , number >
171192 | undefined
172193 > ( )
173194 } )
0 commit comments