@@ -205,6 +205,18 @@ declare module 'mongoose' {
205
205
? ( ResultType extends any [ ] ? Require_id < FlattenMaps < RawDocType > > [ ] : Require_id < FlattenMaps < RawDocType > > )
206
206
: ResultType ;
207
207
208
+ type MergePopulatePaths < RawDocType , ResultType , QueryOp , Paths , TQueryHelpers > = QueryOp extends QueryOpThatReturnsDocument
209
+ ? ResultType extends null
210
+ ? ResultType
211
+ : ResultType extends ( infer U ) [ ]
212
+ ? U extends Document
213
+ ? HydratedDocument < MergeType < RawDocType , Paths > , Record < string , never > , TQueryHelpers > [ ]
214
+ : ( MergeType < U , Paths > ) [ ]
215
+ : ResultType extends Document
216
+ ? HydratedDocument < MergeType < RawDocType , Paths > , Record < string , never > , TQueryHelpers >
217
+ : MergeType < ResultType , Paths >
218
+ : MergeType < ResultType , Paths > ;
219
+
208
220
class Query < ResultType , DocType , THelpers = { } , RawDocType = DocType , QueryOp = 'find' > implements SessionOperation {
209
221
_mongooseOptions : MongooseQueryOptions < DocType > ;
210
222
@@ -602,22 +614,43 @@ declare module 'mongoose' {
602
614
polygon ( ...coordinatePairs : number [ ] [ ] ) : this;
603
615
604
616
/** Specifies paths which should be populated with other documents. */
605
- populate < Paths = { } > (
617
+ populate (
618
+ path : string | string [ ] ,
619
+ select ?: string | any ,
620
+ model ?: string | Model < any , THelpers > ,
621
+ match ?: any
622
+ ) : QueryWithHelpers <
623
+ ResultType ,
624
+ DocType ,
625
+ THelpers ,
626
+ RawDocType ,
627
+ QueryOp
628
+ > ;
629
+ populate (
630
+ options : PopulateOptions | ( PopulateOptions | string ) [ ]
631
+ ) : QueryWithHelpers <
632
+ ResultType ,
633
+ DocType ,
634
+ THelpers ,
635
+ RawDocType ,
636
+ QueryOp
637
+ > ;
638
+ populate < Paths > (
606
639
path : string | string [ ] ,
607
640
select ?: string | any ,
608
641
model ?: string | Model < any , THelpers > ,
609
642
match ?: any
610
643
) : QueryWithHelpers <
611
- UnpackedIntersection < ResultType , Paths > ,
644
+ MergePopulatePaths < RawDocType , ResultType , QueryOp , Paths , THelpers > ,
612
645
DocType ,
613
646
THelpers ,
614
647
UnpackedIntersection < RawDocType , Paths > ,
615
648
QueryOp
616
649
> ;
617
- populate < Paths = { } > (
650
+ populate < Paths > (
618
651
options : PopulateOptions | ( PopulateOptions | string ) [ ]
619
652
) : QueryWithHelpers <
620
- UnpackedIntersection < ResultType , Paths > ,
653
+ MergePopulatePaths < RawDocType , ResultType , QueryOp , Paths , THelpers > ,
621
654
DocType ,
622
655
THelpers ,
623
656
UnpackedIntersection < RawDocType , Paths > ,
0 commit comments