Skip to content

Commit

Permalink
add a-b-a recursion test
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Oct 6, 2022
1 parent 18e267c commit 4cc4b9d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/types/community/collection/recursive-types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,41 @@ recursiveSchemaWithArray.findOne({
name: 3
}
});

// Modeling A -> B -> A recursive type
type One = {
name: string;
two: Two;
};

type Two = {
name: string;
three: Three;
};

type Three = {
name: string;
one: One;
};

// Depth 11 does not get type assertion
expectAssignable<Filter<One>>({
'two.three.one.two.three.one.two.three.one.two.name': 3
});
// Depth 10 and below does
expectNotAssignable<Filter<One>>({
'two.three.one.two.three.one.two.three.one.name': 3
});

// Depth 11 does not get type assertion
expectAssignable<UpdateFilter<One>>({
$set: {
'two.three.one.two.three.one.two.three.one.two.name': 'a'
}
});
// Depth 10 and below does
expectNotAssignable<UpdateFilter<One>>({
$set: {
'two.three.one.two.three.one.two.three.one.name': 3
}
});

0 comments on commit 4cc4b9d

Please sign in to comment.