mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Set more specific types for Backbone Model and Collection url properties. (#20568)
This commit is contained in:
@@ -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() {
|
||||
|
||||
Vendored
+15
-1
@@ -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[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user