Skip to content

Commit

Permalink
fix(types): avoid baffling circular reference when using PopulatedDoc…
Browse files Browse the repository at this point in the history
… with a bidirectional reference

Fix #12136
Re: 11911
  • Loading branch information
vkarpov15 committed Aug 2, 2022
1 parent 7719569 commit 7ed781c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions test/types/populate.test.ts
Expand Up @@ -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<ParentDocument>;
}

class Parent {
child: PopulatedDoc<ChildDocument>;
}

}
2 changes: 1 addition & 1 deletion types/index.d.ts
Expand Up @@ -459,7 +459,7 @@ declare module 'mongoose' {
$pop?: AnyKeys<TSchema> & AnyObject;
$pull?: Mutable<mongodb.PullOperator<TSchema>>;
$push?: Mutable<mongodb.PushOperator<TSchema>>;
$pullAll?: mongodb.PullAllOperator<TSchema>;
$pullAll?: AnyKeys<TSchema> & AnyObject;

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

0 comments on commit 7ed781c

Please sign in to comment.