diff --git a/types/backbone/backbone-tests.ts b/types/backbone/backbone-tests.ts index c074ac57e5..7bf31f0a7b 100644 --- a/types/backbone/backbone-tests.ts +++ b/types/backbone/backbone-tests.ts @@ -115,6 +115,8 @@ class Employee extends Backbone.Model { super(options); this.reports = new EmployeeCollection(); this.reports.url = '../api/employees/' + this.id + '/reports'; + // Test that collection url property can be set as a function returning a string. + this.reports.url = () => { return ""; }; } more() { diff --git a/types/backbone/index.d.ts b/types/backbone/index.d.ts index 42a322e4c2..6475ba1e4a 100644 --- a/types/backbone/index.d.ts +++ b/types/backbone/index.d.ts @@ -100,7 +100,6 @@ declare namespace Backbone { } class ModelBase extends Events { - url: any; parse(response: any, options?: any): any; toJSON(options?: any): any; sync(...arg: any[]): JQueryXHR; @@ -133,6 +132,13 @@ declare namespace Backbone { id: any; idAttribute: string; validationError: any; + + /** + * Returns the relative URL where the model's resource would be located on the server. + * @memberof Model + */ + url: () => string; + urlRoot: any; constructor(attributes?: any, options?: any); @@ -314,6 +320,14 @@ declare namespace Backbone { take(): TModel; take(n: number): TModel[]; toArray(): TModel[]; + + /** + * Sets the url property (or function) on a collection to reference its location on the server. + * + * @memberof Collection + */ + url: string | (() => string); + without(...values: TModel[]): TModel[]; }