@@ -5,6 +5,8 @@ import type { CollectionInfo, ListCollectionsCursor } from '../../src/operations
55
66const db = new MongoClient ( '' ) . db ( ) ;
77
8+ type EitherCollectionInfoResult = CollectionInfo | Pick < CollectionInfo , 'name' | 'type' > ;
9+
810// We default to the CollectionInfo result type
911expectType < ListCollectionsCursor < Pick < CollectionInfo , 'name' | 'type' > | CollectionInfo > > (
1012 db . listCollections ( )
@@ -19,7 +21,7 @@ db.listCollections({ a: 2 });
1921db . listCollections ( { a : 2 } , { batchSize : 2 } ) ;
2022
2123const collections = await db . listCollections ( ) . toArray ( ) ;
22- expectType < ( CollectionInfo | string ) [ ] > ( collections ) ;
24+ expectType < EitherCollectionInfoResult [ ] > ( collections ) ;
2325
2426const nameOnly = await db . listCollections ( { } , { nameOnly : true } ) . toArray ( ) ;
2527expectType < Pick < CollectionInfo , 'name' | 'type' > [ ] > ( nameOnly ) ;
@@ -28,7 +30,7 @@ const fullInfo = await db.listCollections({}, { nameOnly: false }).toArray();
2830expectType < CollectionInfo [ ] > ( fullInfo ) ;
2931
3032const couldBeEither = await db . listCollections ( { } , { nameOnly : Math . random ( ) > 0.5 } ) . toArray ( ) ;
31- expectType < ( CollectionInfo | string ) [ ] > ( couldBeEither ) ;
33+ expectType < EitherCollectionInfoResult [ ] > ( couldBeEither ) ;
3234
3335// Showing here that:
3436// regardless of the option the generic parameter can be used to coerce the result if need be
0 commit comments