mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
feat(backbone): add preinitialize class method (#35419)
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
8d2d0fe08c
commit
fe360db51e
@@ -69,6 +69,14 @@ class SettingDefaults extends Backbone.Model {
|
||||
}
|
||||
}
|
||||
|
||||
// will be invoked when the view is first created, before any instantiation logic is run
|
||||
preinitialize() {
|
||||
this.defaults = {
|
||||
name: "Joe"
|
||||
} as any;
|
||||
|
||||
}
|
||||
|
||||
constructor(attributes?: any, options?: any) {
|
||||
super(attributes, options); // error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
this.defaults = <any>{
|
||||
|
||||
35
types/backbone/index.d.ts
vendored
35
types/backbone/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Backbone 1.3.3
|
||||
// Type definitions for Backbone 1.4.0
|
||||
// Project: http://backbonejs.org/
|
||||
// https://github.com/jashkenas/backbone
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov>
|
||||
@@ -6,6 +6,7 @@
|
||||
// kenjiru <https://github.com/kenjiru>
|
||||
// jjoekoullas <https://github.com/jjoekoullas>
|
||||
// Julian Gonggrijp <https://github.com/jgonggrijp>
|
||||
// Kyle Scully <https://github.com/zieka>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -235,6 +236,14 @@ declare namespace Backbone {
|
||||
|
||||
urlRoot: any;
|
||||
|
||||
/**
|
||||
* For use with models as ES classes. If you define a preinitialize
|
||||
* method, it will be invoked when the Model is first created, before
|
||||
* any instantiation logic is run for the Model.
|
||||
* @see https://backbonejs.org/#Model-preinitialize
|
||||
*/
|
||||
preinitialize(attributes?: any, options?: any): void;
|
||||
|
||||
constructor(attributes?: any, options?: any);
|
||||
initialize(attributes?: any, options?: any): void;
|
||||
|
||||
@@ -311,6 +320,14 @@ declare namespace Backbone {
|
||||
models: TModel[];
|
||||
length: number;
|
||||
|
||||
/**
|
||||
* For use with collections as ES classes. If you define a preinitialize
|
||||
* method, it will be invoked when the Collection is first created and
|
||||
* before any instantiation logic is run for the Collection.
|
||||
* @see https://backbonejs.org/#Collection-preinitialize
|
||||
*/
|
||||
preinitialize(models?: TModel[] | Object[], options?: any): void;
|
||||
|
||||
constructor(models?: TModel[] | Object[], options?: any);
|
||||
initialize(models?: TModel[] | Object[], options?: any): void;
|
||||
|
||||
@@ -452,6 +469,14 @@ declare namespace Backbone {
|
||||
**/
|
||||
routes: RoutesHash | any;
|
||||
|
||||
/**
|
||||
* For use with Router as ES classes. If you define a preinitialize method,
|
||||
* it will be invoked when the Router is first created, before any
|
||||
* instantiation logic is run for the Router.
|
||||
* @see https://backbonejs.org/#Router-preinitialize
|
||||
*/
|
||||
preinitialize(options?: RouterOptions): void;
|
||||
|
||||
constructor(options?: RouterOptions);
|
||||
initialize(options?: RouterOptions): void;
|
||||
route(route: string|RegExp, name: string, callback?: Function): Router;
|
||||
@@ -511,6 +536,14 @@ declare namespace Backbone {
|
||||
**/
|
||||
public static extend(properties: any, classProperties?: any): any;
|
||||
|
||||
/**
|
||||
* For use with views as ES classes. If you define a preinitialize
|
||||
* method, it will be invoked when the view is first created, before any
|
||||
* instantiation logic is run.
|
||||
* @see https://backbonejs.org/#View-preinitialize
|
||||
*/
|
||||
preinitialize(options?: ViewOptions<TModel>): void;
|
||||
|
||||
constructor(options?: ViewOptions<TModel>);
|
||||
initialize(options?: ViewOptions<TModel>): void;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user