From c18eb2ad641d2bb611416eaa75b4f922f0c13c42 Mon Sep 17 00:00:00 2001 From: "Omid K. Rad" Date: Wed, 16 Jul 2014 19:42:09 -0700 Subject: [PATCH] Added test for adding object literals as models --- backbone/backbone-tests.ts | 5 +++++ 1 file changed, 5 insertions(+) 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");