From 7ed781c2745607ab7caaa0f5ce0e47b9548077ee Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 2 Aug 2022 14:48:17 -0400 Subject: [PATCH] fix(types): avoid baffling circular reference when using PopulatedDoc with a bidirectional reference Fix #12136 Re: 11911 --- test/types/populate.test.ts | 14 ++++++++++++++ types/index.d.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/types/populate.test.ts b/test/types/populate.test.ts index 95d0d2f1a58..41a2b7775cd 100644 --- a/test/types/populate.test.ts +++ b/test/types/populate.test.ts @@ -323,3 +323,17 @@ async function gh11955() { populatedParent.children.find(({ name }) => console.log(name)); } + +function gh12136() { + type ChildDocument = Child & Document; + type ParentDocument = Parent & Document; + + class Child { + parent: PopulatedDoc; + } + + class Parent { + child: PopulatedDoc; + } + +} diff --git a/types/index.d.ts b/types/index.d.ts index 084b69296fc..358c48f51a0 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -459,7 +459,7 @@ declare module 'mongoose' { $pop?: AnyKeys & AnyObject; $pull?: Mutable>; $push?: Mutable>; - $pullAll?: mongodb.PullAllOperator; + $pullAll?: AnyKeys & AnyObject; /** @see https://docs.mongodb.com/manual/reference/operator/update-bitwise/ */ $bit?: Record;