Skip to content

Commit 7ed781c

Browse files
committed
fix(types): avoid baffling circular reference when using PopulatedDoc with a bidirectional reference
Fix #12136 Re: 11911
1 parent 7719569 commit 7ed781c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

test/types/populate.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,17 @@ async function gh11955() {
323323

324324
populatedParent.children.find(({ name }) => console.log(name));
325325
}
326+
327+
function gh12136() {
328+
type ChildDocument = Child & Document;
329+
type ParentDocument = Parent & Document;
330+
331+
class Child {
332+
parent: PopulatedDoc<ParentDocument>;
333+
}
334+
335+
class Parent {
336+
child: PopulatedDoc<ChildDocument>;
337+
}
338+
339+
}

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ declare module 'mongoose' {
459459
$pop?: AnyKeys<TSchema> & AnyObject;
460460
$pull?: Mutable<mongodb.PullOperator<TSchema>>;
461461
$push?: Mutable<mongodb.PushOperator<TSchema>>;
462-
$pullAll?: mongodb.PullAllOperator<TSchema>;
462+
$pullAll?: AnyKeys<TSchema> & AnyObject;
463463

464464
/** @see https://docs.mongodb.com/manual/reference/operator/update-bitwise/ */
465465
$bit?: Record<string, mongodb.NumericType>;

0 commit comments

Comments
 (0)