diff --git a/backbone/backbone-tests.ts b/backbone/backbone-tests.ts index bf44c56f7..6b40bb509 100644 --- a/backbone/backbone-tests.ts +++ b/backbone/backbone-tests.ts @@ -140,6 +140,14 @@ function test_collection() { var alphabetical = books.sortBy((book: Book): number => { return null; }); + + var model: Book = new Book({title: "Test", author: "Mike"}); + books.add(model); + var model2: Book = model.collection.first(); + if (model !== model2) { + throw new Error("Error"); + } + } ////////// diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index b58c4652f..db104f480 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -95,6 +95,8 @@ declare module Backbone { attributes: any; changed: any[]; cid: string; + collection: Collection; + /** * Default attributes for the model. It can be an object hash or a method returning an object hash. * For assigning an object hash, do it like this: this.defaults = { attribute: value, ... }; @@ -156,7 +158,6 @@ declare module Backbone { //model: typeof TModel; model: { new(): TModel; }; // workaround models: TModel[]; - collection: TModel; length: number; constructor(models?: TModel[], options?: any);