diff --git a/backbone/backbone-tests.ts b/backbone/backbone-tests.ts index e3fbd6ab8..506fd7bb6 100644 --- a/backbone/backbone-tests.ts +++ b/backbone/backbone-tests.ts @@ -131,6 +131,11 @@ function test_collection() { var book1: Book = new Book({ title: "Title 1", author: "Mike" }); books.add(book1); + // Objects can be added to collection by casting to model type. + // Compiler will check if object properties are valid for the cast. + // This gives better type checking than declaring an `any` overload. + books.add({ title: "Title 2", author: "Mikey" }); + var model: Book = book1.collection.first(); if (model !== book1) { throw new Error("Error");