File tree Expand file tree Collapse file tree
packages/vue-query/src/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { queryKey } from '@tanstack/query-test-utils'
55import { QueryClient } from '../queryClient'
66import { queryOptions } from '../queryOptions'
77import { useQuery } from '../useQuery'
8+ import type { MaybeRefDeep } from '../types'
89
910// Regression test for exported queryOptions inference under declaration emit.
1011// TypeScript should be able to name the return type without expanding the
@@ -403,17 +404,18 @@ describe('queryOptions', () => {
403404 } ) ,
404405 )
405406 expectTypeOf ( inlineData ) . toEqualTypeOf < { id : PostId } | undefined > ( )
407+ } )
406408
407- const brandedObjectOptions = queryOptions ( {
408- queryKey : [
409- 'post' ,
410- { __brand : 'post' as const , postId : ref ( '123' ) } ,
411- ] as const ,
412- queryFn : ( ) => Promise . resolve ( { id : postId } ) ,
413- } )
414- const { data : brandedObjectData } = reactive ( useQuery ( brandedObjectOptions ) )
415- expectTypeOf ( brandedObjectData ) . toEqualTypeOf < { id : PostId } | undefined > ( )
416- expectTypeOf ( brandedObjectOptions . queryKey [ 1 ] . postId ) . toMatchTypeOf <
409+ it ( 'should recursively unwrap objects with a __brand property' , ( ) => {
410+ const options = {
411+ __brand : 'post' as const ,
412+ postId : ref ( '123' ) ,
413+ } satisfies MaybeRefDeep < {
414+ __brand : 'post'
415+ postId : string
416+ } >
417+
418+ expectTypeOf ( options . postId ) . toMatchTypeOf <
417419 string | ReturnType < typeof ref >
418420 > ( )
419421 } )
You can’t perform that action at this time.
0 commit comments