From fe66d4219d30a388a57a3d4071ca04b73aac3634 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Thu, 4 Aug 2016 14:43:15 +0200 Subject: [PATCH 1/2] Updated backbone to version 1.3 --- backbone/backbone-global.d.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/backbone/backbone-global.d.ts b/backbone/backbone-global.d.ts index d86305ee3d..3d27e35b5c 100644 --- a/backbone/backbone-global.d.ts +++ b/backbone/backbone-global.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Backbone 1.0.0 +// Type definitions for Backbone 1.3.3 // Project: http://backbonejs.org/ // Definitions by: Boris Yankov , Natan Vivo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -109,9 +109,15 @@ declare namespace Backbone { attributes: any; changed: any[]; + cidPrefix: string; cid: string; collection: Collection; + private _changing: boolean; + private _previousAttributes : any; + private _pending: boolean; + + /** * 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, ... }; @@ -147,7 +153,7 @@ declare namespace Backbone { /*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model; set(obj: any, options?: ModelSetOptions): Model; - changedAttributes(attributes?: any): any[]; + changedAttributes(attributes?: any): any | boolean; clear(options?: Silenceable): any; clone(): Model; destroy(options?: ModelDestroyOptions): any; @@ -178,6 +184,7 @@ declare namespace Backbone { omit(fn: (value: any, key: any, object: any) => any): any; chain(): any; isEmpty(): boolean; + matches(attrs: any): boolean; } class Collection extends ModelBase { @@ -208,6 +215,7 @@ declare namespace Backbone { * Get a model from a collection, specified by an id, a cid, or by passing in a model. **/ get(id: number|string|Model): TModel; + has(key: number|string|Model): boolean; create(attributes: any, options?: ModelSaveOptions): TModel; pluck(attribute: string): any[]; push(model: TModel, options?: AddOptions): TModel; @@ -221,10 +229,12 @@ declare namespace Backbone { unshift(model: TModel, options?: AddOptions): TModel; where(properties: any): TModel[]; findWhere(properties: any): TModel; + modelId(attrs: any) : any private _prepareModel(attributes?: any, options?: any): any; private _removeReference(model: TModel): void; private _onModelEvent(event: string, model: TModel, collection: Collection, options: any): void; + private _isModel(obj: any) : obj is Model; /** * Return a shallow copy of this collection's models, using the same options as native Array#slice. @@ -314,6 +324,8 @@ declare namespace Backbone { navigate(fragment: string, options?: NavigateOptions): Router; navigate(fragment: string, trigger?: boolean): Router; + execute(callback: Function, args: any[], name: string) : void; + private _bindRoutes(): void; private _routeToRegExp(route: string): RegExp; private _extractParameters(route: RegExp, fragment: string): string[]; @@ -330,9 +342,14 @@ declare namespace Backbone { getHash(window?: Window): string; getFragment(fragment?: string): string; + decodeFragment(fragment: string): string; + getSearch(): string; stop(): void; route(route: string, callback: Function): number; checkUrl(e?: any): void; + getPath(): string; + matchRoot(): boolean; + atRoot(): boolean; loadUrl(fragmentOverride?: string): boolean; navigate(fragment: string, options?: any): boolean; static started: boolean; From f614c7b3d4946dc60ec44af39bee91c52d8c2eb6 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 5 Aug 2016 23:44:52 +0200 Subject: [PATCH 2/2] Changed changedAttributes method to return any, instead of any | boolean. And added some JSDoc to describe its behaviour. --- backbone/backbone-global.d.ts | 9 ++++++++- backbone/backbone.d.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backbone/backbone-global.d.ts b/backbone/backbone-global.d.ts index 3d27e35b5c..3dca269eb0 100644 --- a/backbone/backbone-global.d.ts +++ b/backbone/backbone-global.d.ts @@ -153,7 +153,14 @@ declare namespace Backbone { /*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model; set(obj: any, options?: ModelSetOptions): Model; - changedAttributes(attributes?: any): any | boolean; + /** + * Return an object containing all the attributes that have changed, or + * false if there are no changed attributes. Useful for determining what + * parts of a view need to be updated and/or what attributes need to be + * persisted to the server. Unset attributes will be set to undefined. + * You can also pass an attributes object to diff against the model, + * determining if there *would be* a change. */ + changedAttributes(attributes?: any): any; clear(options?: Silenceable): any; clone(): Model; destroy(options?: ModelDestroyOptions): any; diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 65e273a61f..d3887b4176 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Backbone 1.0.0 +// Type definitions for Backbone 1.3.3 // Project: http://backbonejs.org/ // Definitions by: Boris Yankov , Natan Vivo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped