11import { mount } from '@vue/test-utils'
2- import { describe , expect , it } from 'vitest'
2+ import { describe , expect , expectTypeOf , it } from 'vitest'
33import {
44 collection as originalCollection ,
55 CollectionReference ,
@@ -40,7 +40,7 @@ describe(
4040 options,
4141 ref = collection ( ) ,
4242 } : {
43- options ?: UseCollectionOptions
43+ options ?: UseCollectionOptions < T [ ] >
4444 ref ?: MaybeRefOrGetter < _Nullable < CollectionReference < T > > >
4545 } = { } ) {
4646 let data ! : _RefFirestore < VueFirestoreQueryData < T > >
@@ -79,7 +79,7 @@ describe(
7979 options,
8080 ref,
8181 } : {
82- options ?: UseCollectionOptions
82+ options ?: UseCollectionOptions < AppModelType [ ] >
8383 ref ?: MaybeRefOrGetter < _Nullable < Query < AppModelType , DbModelType > > >
8484 } = { } ) {
8585 let data ! : _RefFirestore < VueFirestoreQueryData < AppModelType > >
@@ -88,7 +88,6 @@ describe(
8888 defineComponent ( {
8989 template : 'no' ,
9090 setup ( ) {
91- // @ts -expect-error: generic forced
9291 data = useCollection (
9392 // split for ts
9493 ref ,
@@ -490,7 +489,17 @@ describe(
490489 // @ts -expect-error: no id with custom converter
491490 ) . value [ 0 ] . id
492491
493- expectType < Ref < TodoI [ ] > > ( useCollection < TodoI > ( collection ( db , 'todos' ) ) )
492+ expectTypeOf ( useCollection < TodoI > ( collection ( db , 'todos' ) ) ) . toMatchTypeOf <
493+ Ref < TodoI [ ] >
494+ > ( )
495+
496+ // TODO: can this be improved to not have the generic
497+ expectTypeOf (
498+ useCollection < TodoI > ( collection ( db , 'todos' ) , {
499+ target : ref < TodoI [ ] > ( [ ] ) ,
500+ } )
501+ ) . toMatchTypeOf < Ref < TodoI [ ] > > ( )
502+
494503 expectType < Ref < TodoI [ ] > > (
495504 useCollection < TodoI > ( collection ( db , 'todos' ) ) . data
496505 )
0 commit comments