Skip to content

Commit 4cc4b9d

Browse files
committed
add a-b-a recursion test
1 parent 18e267c commit 4cc4b9d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/types/community/collection/recursive-types.test-d.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,41 @@ recursiveSchemaWithArray.findOne({
228228
name: 3
229229
}
230230
});
231+
232+
// Modeling A -> B -> A recursive type
233+
type One = {
234+
name: string;
235+
two: Two;
236+
};
237+
238+
type Two = {
239+
name: string;
240+
three: Three;
241+
};
242+
243+
type Three = {
244+
name: string;
245+
one: One;
246+
};
247+
248+
// Depth 11 does not get type assertion
249+
expectAssignable<Filter<One>>({
250+
'two.three.one.two.three.one.two.three.one.two.name': 3
251+
});
252+
// Depth 10 and below does
253+
expectNotAssignable<Filter<One>>({
254+
'two.three.one.two.three.one.two.three.one.name': 3
255+
});
256+
257+
// Depth 11 does not get type assertion
258+
expectAssignable<UpdateFilter<One>>({
259+
$set: {
260+
'two.three.one.two.three.one.two.three.one.two.name': 'a'
261+
}
262+
});
263+
// Depth 10 and below does
264+
expectNotAssignable<UpdateFilter<One>>({
265+
$set: {
266+
'two.three.one.two.three.one.two.three.one.name': 3
267+
}
268+
});

0 commit comments

Comments
 (0)