There is a small limitation in type checking for recursive types in 4.11.0. Recursive types which reference themselves will compile safely but do not have type checking.
The code example in the release notes will successfully compile, but it will not type check the Filter predicate.
The following is an example that shows a scenario where type checking is enforced.
interface Author {
name: string;
bestBook: Book;
}
interface Book {
title: string;
author: Author;
}
let authors: Collection<Author>
// below a depth of 8, type checking is enforced
authors.findOne({ 'bestBook.author.bestBook.title': 25 }})
// ✅ expected compilation error is thrown: "title must be a string"
// at a depth greater than 8 code compiles but is not type checked (9 deep in this example)
authors.findOne({ 'bestBook.author.bestBook.author.bestBook.author.bestBook.author.name': 25 })
// ⛔️ perhaps unexpected, no compilation error is thrown because the key is too deeply nested
2 Likes