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 4656109
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/types/community/collection/recursive-types.test-d.ts
Expand Up @@ -228,3 +228,37 @@ recursiveSchemaWithArray.findOne({
name: 3
}
});

// Modeling A -> B -> C -> D -> A recursive type
type A = {
name: string;
b: B;
};

type B = {
name: string;
c: C;
};

type C = {
name: string;
d: D;
};

type D = {
name: string;
a: A;
};

expectAssignable<Filter<A>>({
'b.c.d.a.b.c.d.a.b.name': 'a'
});

expectNotAssignable<Filter<A>>({
'b.c.d.a.b.c.d.a.b.name': 2
});

// why does this blow up
expectAssignable<UpdateFilter<A>>({
$set: { 'b.c.d.a.b.c.d.a.b.c.name': 'a' }
});

0 comments on commit 4656109

Please sign in to comment.