From ea103215ea8fa2493325a1b8d2327f47e6a9d6de Mon Sep 17 00:00:00 2001 From: Frederik Wordenskjold Date: Wed, 15 Jul 2015 16:20:54 +0200 Subject: [PATCH] Make it possible to initialize a Backbone.Collection from raw objects The following syntax is supported in Backbone, but is currently not compileable in Typescript: var data = [ { id: 1, bar: 'foo' }, { id: 2, bar: 'baz' } ]; var myCollection = new Backbone.Collection(data); As of now, the constructor expects an array of models. I've added the Object[] parameter type, in addition to the TModel[] type to support this syntax. --- backbone/backbone.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 9d54361d5e..08cb396b27 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -173,8 +173,8 @@ declare module Backbone { models: TModel[]; length: number; - constructor(models?: TModel[], options?: any); - initialize(models?: TModel[], options?: any): void; + constructor(models?: TModel[] | Object[], options?: any); + initialize(models?: TModel[] | Object[], options?: any): void; fetch(options?: CollectionFetchOptions): JQueryXHR;