diff --git a/backbone-relational/backbone-relational.d.ts b/backbone-relational/backbone-relational.d.ts
index 56dd2e9e83..4f4aa45cc6 100644
--- a/backbone-relational/backbone-relational.d.ts
+++ b/backbone-relational/backbone-relational.d.ts
@@ -5,12 +5,15 @@
///
-
///
declare module Backbone {
- export class RelationalModel extends Model {
- static extend(properties:any, classProperties?:any):any; // do not use, prefer TypeScript's extend functionality
+ class RelationalModel extends Model {
+ /**
+ * Do not use, prefer TypeScript's extend functionality.
+ **/
+ //private static extend(properties:any, classProperties?:any):any;
+
relations:any;
subModelTypes:any;
subModelTypeAttribute:any;
@@ -58,7 +61,7 @@ declare module Backbone {
setRelated(related:Model):void;
- setRelated(related:Collection):void;
+ setRelated(related:Collection):void;
getReverseRelations(model:RelationalModel):Relation;
@@ -78,15 +81,15 @@ declare module Backbone {
setKeyContents(keyContents:number[]):void;
- setKeyContents(keyContents:Collection):void;
+ setKeyContents(keyContents:Collection):void;
onChange(model:Model, attr:any, options:any):void;
- handleAddition(model:Model, coll:Collection, options:any):void;
+ handleAddition(model:Model, coll:Collection, options:any):void;
- handleRemoval(model:Model, coll:Collection, options:any):void;
+ handleRemoval(model:Model, coll:Collection, options:any):void;
- handleReset(coll:Collection, options:any):void;
+ handleReset(coll:Collection, options:any):void;
tryAddRelated(model:Model, coll:any, options:any):void;
@@ -135,9 +138,9 @@ declare module Backbone {
processOrphanRelations():void;
- retroFitRelation(relation:RelationalModel, create:boolean):Collection;
+ retroFitRelation(relation:RelationalModel, create:boolean):Collection;
- getCollection(type:RelationalModel, create:boolean):Collection;
+ getCollection(type:RelationalModel, create:boolean):Collection;
getObjectByName(name:string):any;
@@ -158,7 +161,7 @@ declare module Backbone {
update(model:RelationalModel):void;
- unregister(model:RelationalModel, collection:Collection, options:any):void;
+ unregister(model:RelationalModel, collection:Collection, options:any):void;
reset():void;
diff --git a/backbone/backbone-tests.ts b/backbone/backbone-tests.ts
index c1292c1c25..bf44c56f77 100644
--- a/backbone/backbone-tests.ts
+++ b/backbone/backbone-tests.ts
@@ -4,7 +4,7 @@
function test_events() {
var object = new Backbone.Events();
- object.on("alert", (msg) => alert("Triggered " + msg));
+ object.on("alert", (eventName: string) => alert("Triggered " + eventName));
object.trigger("alert", "an event");
@@ -18,48 +18,74 @@ function test_events() {
object.off();
}
+class SettingDefaults extends Backbone.Model {
+
+ // 'defaults' could be set in one of the following ways:
+
+ defaults() {
+ return {
+ name: "Joe"
+ }
+ }
+
+ constructor(attributes?: any, options?: any) {
+ this.defaults = {
+ name: "Joe"
+ }
+ // super has to come last
+ super(attributes, options);
+ }
+
+ // or set it like this
+ initialize() {
+ this.defaults = {
+ name: "Joe"
+ }
+
+ }
+
+ // same patterns could be used for setting 'Router.routes' and 'View.events'
+}
+
+class Sidebar extends Backbone.Model {
+
+ promptColor() {
+ var cssColor = prompt("Please enter a CSS color:");
+ this.set({ color: cssColor });
+ }
+}
+
+class Note extends Backbone.Model {
+ initialize() { }
+ author() { }
+ coordinates() { }
+ allowedToEdit(account: any) {
+ return true;
+ }
+}
+
+class PrivateNote extends Note {
+ allowedToEdit(account: any) {
+ return account.owns(this);
+ }
+
+ set(attributes: any, options?: any): Backbone.Model {
+ return Backbone.Model.prototype.set.call(this, attributes, options);
+ }
+}
+
function test_models() {
- var Sidebar = Backbone.Model.extend({
- promptColor: function () {
- var cssColor = prompt("Please enter a CSS color:");
- this.set({ color: cssColor });
- }
- });
-
var sidebar = new Sidebar();
- sidebar.on('change:color', (model, color) => $('#sidebar').css({ background: color }));
+ sidebar.on('change:color', (model: {}, color: string) => $('#sidebar').css({ background: color }));
sidebar.set({ color: 'white' });
sidebar.promptColor();
- ////////
-
- var Note = Backbone.Model.extend({
- initialize: () => { },
- author: () => { },
- coordinates: () => { },
- allowedToEdit: (account) => {
- return true;
- }
- });
-
- var PrivateNote = Note.extend({
-
- allowedToEdit: function (account) {
- return account.owns(this);
- }
-
- });
-
//////////
- var note = Backbone.Model.extend({
- set: function (attributes, options) {
- Backbone.Model.prototype.set.call(this, attributes, options);
- }
- });
+ var note = new PrivateNote();
- note.get("title")
+ note.get("title");
note.set({ title: "March 20", content: "In his eyes she eclipses..." });
@@ -69,7 +95,7 @@ function test_models() {
class Employee extends Backbone.Model {
reports: EmployeeCollection;
- constructor (options? ) {
+ constructor(attributes?: any, options?: any) {
super(options);
this.reports = new EmployeeCollection();
this.reports.url = '../api/employees/' + this.id + '/reports';
@@ -80,29 +106,38 @@ class Employee extends Backbone.Model {
}
}
-class EmployeeCollection extends Backbone.Collection {
- findByName(key) { }
+class EmployeeCollection extends Backbone.Collection {
+ findByName(key: any) { }
}
+
+class Book extends Backbone.Model {
+ title: string;
+ author: string;
+}
+
+class Library extends Backbone.Collection {
+ model: typeof Book;
+}
+
+class Books extends Backbone.Collection { }
+
function test_collection() {
- var Book: Backbone.Model;
- var Library = Backbone.Collection.extend({
- model: Book
+
+ var books = new Library();
+
+ books.each(book => {
+ book.get("title");
});
- var Books: Backbone.Collection;
-
- Books.each(function (book) {
- });
-
- var titles = Books.map(function (book) {
+ var titles = books.map(book => {
return book.get("title");
});
- var publishedBooks = Books.filter(function (book) {
+ var publishedBooks = books.filter(book => {
return book.get("published") === true;
});
- var alphabetical = Books.sortBy(function (book) {
+ var alphabetical = books.sortBy((book: Book): number => {
return null;
});
}
@@ -121,26 +156,26 @@ module v1Changes {
function test_listenTo() {
var model = new Employee;
- var view = new Backbone.View;
+ var view = new Backbone.View();
view.listenTo(model, 'invalid', () => { });
}
function test_listenToOnce() {
var model = new Employee;
- var view = new Backbone.View;
+ var view = new Backbone.View();
view.listenToOnce(model, 'invalid', () => { });
}
function test_stopListening() {
var model = new Employee;
- var view = new Backbone.View;
+ var view = new Backbone.View();
view.stopListening(model, 'invalid', () => { });
view.stopListening(model, 'invalid');
view.stopListening(model);
}
}
- module modelandcollection {
+ module ModelAndCollection {
function test_url() {
Employee.prototype.url = () => '/employees';
EmployeeCollection.prototype.url = () => '/employees';
@@ -168,7 +203,7 @@ module v1Changes {
}
}
- module model {
+ module Model {
function test_validationError() {
var model = new Employee;
if (model.validationError) {
@@ -195,17 +230,17 @@ module v1Changes {
model.destroy({
wait: true,
success: (m?, response?, options?) => { },
- error: (m?, jqxhr?: JQueryXHR, options?) => { }
+ error: (m?, jqxhr?, options?) => { }
});
model.destroy({
success: (m?, response?, options?) => { },
- error: (m?, jqxhr?: JQueryXHR) => { }
+ error: (m?, jqxhr?) => { }
});
model.destroy({
success: () => { },
- error: (m?, jqxhr?: JQueryXHR) => { }
+ error: (m?, jqxhr?) => { }
});
}
@@ -220,7 +255,7 @@ module v1Changes {
wait: true,
validate: false,
success: (m?, response?, options?) => { },
- error: (m?, jqxhr?: JQueryXHR, options?) => { }
+ error: (m?, jqxhr?, options?) => { }
});
model.save({
@@ -229,7 +264,7 @@ module v1Changes {
},
{
success: () => { },
- error: (m?, jqxhr?: JQueryXHR) => { }
+ error: (m?, jqxhr?) => { }
});
}
@@ -240,7 +275,7 @@ module v1Changes {
}
}
- module collection {
+ module Collection {
function test_fetch() {
var collection = new EmployeeCollection;
collection.fetch({ reset: true });
@@ -256,7 +291,7 @@ module v1Changes {
}
}
- module router {
+ module Router {
function test_navigate() {
var router = new Backbone.Router;
@@ -264,4 +299,4 @@ module v1Changes {
router.navigate('/employees', true);
}
}
-}
\ No newline at end of file
+}
diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts
index d94e9172bf..6fa7e6d608 100644
--- a/backbone/backbone.d.ts
+++ b/backbone/backbone.d.ts
@@ -6,6 +6,7 @@
///
+///
declare module Backbone {
@@ -67,7 +68,7 @@ declare module Backbone {
}
class Events {
- on(eventName: any, callback?: Function, context?: any): any;
+ on(eventName: string, callback?: Function, context?: any): any;
off(eventName?: string, callback?: Function, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: Function, context?: any): any;
@@ -86,17 +87,22 @@ declare module Backbone {
sync(...arg: any[]): JQueryXHR;
}
- interface OptionalDefaults {
- defaults?(): any;
- }
+ class Model extends ModelBase {
- class Model extends ModelBase implements OptionalDefaults {
-
- static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
+ /**
+ * Do not use, prefer TypeScript's extend functionality.
+ **/
+ private static extend(properties: any, classProperties?: any): any;
attributes: any;
changed: any[];
cid: string;
+ /**
+ * 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, ... };
+ * That works only if you set it in the constructor or the initialize method.
+ **/
+ defaults(): any;
id: any;
idAttribute: string;
validationError: any;
@@ -127,7 +133,7 @@ declare module Backbone {
unset(attribute: string, options?: Silenceable): Model;
validate(attributes: any, options?: any): any;
- _validate(attrs: any, options: any): boolean;
+ private _validate(attrs: any, options: any): boolean;
// mixins from underscore
@@ -141,115 +147,125 @@ declare module Backbone {
omit(...keys: string[]): any;
}
- class Collection extends ModelBase {
+ class Collection extends ModelBase {
- static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
+ /**
+ * Do not use, prefer TypeScript's extend functionality.
+ **/
+ private static extend(properties: any, classProperties?: any): any;
- model: any;
- models: any;
- collection: Model;
+ // TODO: this really has to be typeof TModel
+ //model: typeof TModel;
+ model: { new(): TModel; }; // workaround
+ models: TModel[];
+ collection: TModel;
length: number;
- constructor(models?: any, options?: any);
+ constructor(models?: TModel[], options?: any);
fetch(options?: CollectionFetchOptions): JQueryXHR;
- comparator(element: Model): any;
- comparator(compare: Model, to?: Model): any;
+ comparator(element: TModel): number;
+ comparator(compare: TModel, to?: TModel): number;
- add(model: Model, options?: AddOptions): Collection;
- add(model: any, options?: AddOptions): Collection;
- add(models: Model[], options?: AddOptions): Collection;
- add(models: any[], options?: AddOptions): Collection;
- at(index: number): Model;
- get(id: any): Model;
- create(attributes: any, options?: ModelSaveOptions): Model;
+ add(model: TModel, options?: AddOptions): Collection;
+ add(models: TModel[], options?: AddOptions): Collection;
+ at(index: number): TModel;
+ get(id: string): TModel;
+ create(attributes: any, options?: ModelSaveOptions): TModel;
pluck(attribute: string): any[];
- push(model: Model, options?: AddOptions): Model;
- pop(options?: Silenceable): Model;
- remove(model: Model, options?: Silenceable): Model;
- remove(models: Model[], options?: Silenceable): Model[];
- reset(models?: Model[], options?: Silenceable): Model[];
- reset(models?: any[], options?: Silenceable): Model[];
- set(models?: any[], options?: Silenceable): Model[];
- shift(options?: Silenceable): Model;
- sort(options?: Silenceable): Collection;
- unshift(model: Model, options?: AddOptions): Model;
- where(properies: any): Model[];
- findWhere(properties: any): Model;
+ push(model: TModel, options?: AddOptions): TModel;
+ pop(options?: Silenceable): TModel;
+ remove(model: TModel, options?: Silenceable): TModel;
+ remove(models: TModel[], options?: Silenceable): TModel[];
+ reset(models?: TModel[], options?: Silenceable): TModel[];
+ set(models?: TModel[], options?: Silenceable): TModel[];
+ shift(options?: Silenceable): TModel;
+ sort(options?: Silenceable): Collection;
+ unshift(model: TModel, options?: AddOptions): TModel;
+ where(properies: any): TModel[];
+ findWhere(properties: any): TModel;
- _prepareModel(attrs?: any, options?: any): any;
- _removeReference(model: Model): void;
- _onModelEvent(event: string, model: Model, collection: Collection, options: any): void;
+ private _prepareModel(attrs?: any, options?: any): any;
+ private _removeReference(model: TModel): void;
+ private _onModelEvent(event: string, model: TModel, collection: Collection, options: any): void;
// mixins from underscore
- all(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
- any(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
- collect(iterator: (element: Model, index: number, context?: any) => any[], context?: any): any[];
+ all(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
+ any(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
+ collect(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[];
chain(): any;
- compact(): Model[];
+ compact(): TModel[];
contains(value: any): boolean;
- countBy(iterator: (element: Model, index: number) => any): any[];
- countBy(attribute: string): any[];
+ countBy(iterator: (element: TModel, index: number) => any): _.Dictionary;
+ countBy(attribute: string): _.Dictionary;
detect(iterator: (item: any) => boolean, context?: any): any; // ???
- difference(...model: Model[]): Model[];
- drop(): Model;
- drop(n: number): Model[];
- each(iterator: (element: Model, index: number, list?: any) => void , context?: any): any;
- every(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
- filter(iterator: (element: Model, index: number) => boolean, context?: any): Model[];
- find(iterator: (element: Model, index: number) => boolean, context?: any): Model;
- first(): Model;
- first(n: number): Model[];
- flatten(shallow?: boolean): Model[];
- foldl(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any;
- forEach(iterator: (element: Model, index: number, list?: any) => void , context?: any): any;
+ difference(...model: TModel[]): TModel[];
+ drop(): TModel;
+ drop(n: number): TModel[];
+ each(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
+ every(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
+ filter(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
+ find(iterator: (element: TModel, index: number) => boolean, context?: any): TModel;
+ first(): TModel;
+ first(n: number): TModel[];
+ flatten(shallow?: boolean): TModel[];
+ foldl(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
+ forEach(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
+ groupBy(iterator: (element: TModel, index: number) => string, context?: any): _.Dictionary;
+ groupBy(attribute: string, context?: any): _.Dictionary;
include(value: any): boolean;
- indexOf(element: Model, isSorted?: boolean): number;
- initial(): Model;
- initial(n: number): Model[];
- inject(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any;
- intersection(...model: Model[]): Model[];
+ indexOf(element: TModel, isSorted?: boolean): number;
+ initial(): TModel;
+ initial(n: number): TModel[];
+ inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
+ intersection(...model: TModel[]): TModel[];
isEmpty(object: any): boolean;
invoke(methodName: string, arguments?: any[]): any;
- last(): Model;
- last(n: number): Model[];
- lastIndexOf(element: Model, fromIndex?: number): number;
- map(iterator: (element: Model, index: number, context?: any) => any[], context?: any): any[];
- max(iterator?: (element: Model, index: number) => any, context?: any): Model;
- min(iterator?: (element: Model, index: number) => any, context?: any): Model;
+ last(): TModel;
+ last(n: number): TModel[];
+ lastIndexOf(element: TModel, fromIndex?: number): number;
+ map(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[];
+ max(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
+ min(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
object(...values: any[]): any[];
- reduce(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any;
+ reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
select(iterator: any, context?: any): any[];
size(): number;
shuffle(): any[];
- some(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
- sortBy(iterator: (element: Model, index: number) => number, context?: any): Model[];
- sortBy(attribute: string, context?: any): Model[];
- sortedIndex(element: Model, iterator?: (element: Model, index: number) => number): number;
+ some(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
+ sortBy(iterator: (element: TModel, index: number) => number, context?: any): TModel[];
+ sortBy(attribute: string, context?: any): TModel[];
+ sortedIndex(element: TModel, iterator?: (element: TModel, index: number) => number): number;
range(stop: number, step?: number): any;
range(start: number, stop: number, step?: number): any;
- reduceRight(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any[];
- reject(iterator: (element: Model, index: number) => boolean, context?: any): Model[];
- rest(): Model;
- rest(n: number): Model[];
- tail(): Model;
- tail(n: number): Model[];
+ reduceRight(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any[];
+ reject(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
+ rest(): TModel;
+ rest(n: number): TModel[];
+ tail(): TModel;
+ tail(n: number): TModel[];
toArray(): any[];
- union(...model: Model[]): Model[];
- uniq(isSorted?: boolean, iterator?: (element: Model, index: number) => boolean): Model[];
- without(...values: any[]): Model[];
- zip(...model: Model[]): Model[];
+ union(...model: TModel[]): TModel[];
+ uniq(isSorted?: boolean, iterator?: (element: TModel, index: number) => boolean): TModel[];
+ without(...values: any[]): TModel[];
+ zip(...model: TModel[]): TModel[];
}
- interface OptionalRoutes {
- routes?(): any;
- }
+ class Router extends Events {
- class Router extends Events implements OptionalRoutes {
+ /**
+ * Do not use, prefer TypeScript's extend functionality.
+ **/
+ private static extend(properties: any, classProperties?: any): any;
- static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
+ /**
+ * Routes hash or a method returning the routes hash that maps URLs with parameters to methods on your Router.
+ * For assigning routes as object hash, do it like this: this.routes = { "route": callback, ... };
+ * That works only if you set it in the constructor or the initialize method.
+ **/
+ routes(): any;
constructor(options?: RouterOptions);
initialize(options?: RouterOptions): void;
@@ -257,9 +273,9 @@ declare module Backbone {
navigate(fragment: string, options?: NavigateOptions): Router;
navigate(fragment: string, trigger?: boolean): Router;
- _bindRoutes(): void;
- _routeToRegExp(route: string): RegExp;
- _extractParameters(route: RegExp, fragment: string): string[];
+ private _bindRoutes(): void;
+ private _routeToRegExp(route: string): RegExp;
+ private _extractParameters(route: RegExp, fragment: string): string[];
}
var history: History;
@@ -279,14 +295,14 @@ declare module Backbone {
loadUrl(fragmentOverride: string): boolean;
navigate(fragment: string, options?: any): boolean;
started: boolean;
- options: any;
-
- _updateHash(location: Location, fragment: string, replace: boolean): void;
+ options: any;
+
+ private _updateHash(location: Location, fragment: string, replace: boolean): void;
}
- interface ViewOptions {
- model?: Backbone.Model;
- collection?: Backbone.Collection;
+ interface ViewOptions {
+ model?: TModel;
+ collection?: Backbone.Collection;
el?: any;
id?: string;
className?: string;
@@ -294,35 +310,41 @@ declare module Backbone {
attributes?: any[];
}
- interface OptionalEvents {
- events?(): any;
- }
+ class View extends Events {
- class View extends Events implements OptionalEvents {
+ /**
+ * Do not use, prefer TypeScript's extend functionality.
+ **/
+ private static extend(properties: any, classProperties?: any): any;
- static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
+ constructor(options?: ViewOptions);
- constructor(options?: ViewOptions);
+ /**
+ * Events hash or a method returning the events hash that maps events/selectors to methods on your View.
+ * For assigning events as object hash, do it like this: this.events = { "event:selector": callback, ... };
+ * That works only if you set it in the constructor or the initialize method.
+ **/
+ events(): any;
$(selector: string): JQuery;
- model: Model;
- collection: Collection;
- make(tagName: string, attrs?: any, opts?: any): View;
- setElement(element: HTMLElement, delegate?: boolean): View;
- setElement(element: JQuery, delegate?: boolean): View;
+ model: TModel;
+ collection: Collection;
+ //template: (json, options?) => string;
+ make(tagName: string, attrs?: any, opts?: any): View;
+ setElement(element: HTMLElement, delegate?: boolean): View;
+ setElement(element: JQuery, delegate?: boolean): View;
id: string;
cid: string;
className: string;
tagName: string;
- options: any;
el: any;
$el: JQuery;
- setElement(element: any): View;
+ setElement(element: any): View;
attributes: any;
$(selector: any): JQuery;
- render(): View;
- remove(): View;
+ render(): View;
+ remove(): View;
make(tagName: any, attributes?: any, content?: any): any;
delegateEvents(events?: any): any;
undelegateEvents(): any;
@@ -333,14 +355,12 @@ declare module Backbone {
// SYNC
function sync(method: string, model: Model, options?: JQueryAjaxSettings): any;
function ajax(options?: JQueryAjaxSettings): JQueryXHR;
- var emulateHTTP: boolean;
+ var emulateHTTP: boolean;
var emulateJSONBackbone: boolean;
// Utility
function noConflict(): typeof Backbone;
function setDomLibrary(jQueryNew: any): any;
-
- var $: JQueryStatic;
}
declare module "backbone" {
diff --git a/backgrid/backgrid-tests.ts b/backgrid/backgrid-tests.ts
index 0c681a1d34..a29a4ae7e6 100644
--- a/backgrid/backgrid-tests.ts
+++ b/backgrid/backgrid-tests.ts
@@ -23,7 +23,7 @@ class TestModel extends Backbone.Model {
}
-class TestCollection extends Backbone.Collection {
+class TestCollection extends Backbone.Collection {
constructor(models?: any, options?: any) {
this.model = TestModel;
@@ -41,11 +41,11 @@ class TestCollection extends Backbone.Collection {
}
}
-class TestView extends Backbone.View {
+class TestView extends Backbone.View {
gridView: Backgrid.Grid;
testCollection: TestCollection;
- constructor(viewOptions?: Backbone.ViewOptions) {
+ constructor(viewOptions?: Backbone.ViewOptions) {
this.testCollection = new TestCollection();
this.gridView = new Backgrid.Grid({
columns: [new Backgrid.Column({name: "FirstName", cell: "string", label: "First Name"}),
diff --git a/backgrid/backgrid.d.ts b/backgrid/backgrid.d.ts
index 73cb12450e..fcae05d800 100644
--- a/backgrid/backgrid.d.ts
+++ b/backgrid/backgrid.d.ts
@@ -9,20 +9,20 @@ declare module Backgrid {
interface GridOptions {
columns: Column[];
- collection: Backbone.Collection;
+ collection: Backbone.Collection;
header: Header;
body: Body;
row: Row;
footer: Footer;
}
- class Header extends Backbone.View {
+ class Header extends Backbone.View {
}
- class Footer extends Backbone.View {
+ class Footer extends Backbone.View {
}
- class Row extends Backbone.View {
+ class Row extends Backbone.View {
}
class Command {
@@ -50,19 +50,19 @@ declare module Backgrid {
initialize(options?: any);
}
- class Body extends Backbone.View {
+ class Body extends Backbone.View {
tagName: string;
initialize(options?: any);
- insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any);
+ insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any);
moveToNextCell(model: Backbone.Model, cell: Column, command: Command);
refresh(): Body;
remove(): Body;
- removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any);
+ removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any);
render(): Body;
}
- class Grid extends Backbone.View {
+ class Grid extends Backbone.View {
body: Backgrid.Body;
className: string;
footer: any;
@@ -72,10 +72,10 @@ declare module Backgrid {
initialize(options: any);
getSelectedModels(): Backbone.Model[];
insertColumn(...options: any[]): Grid;
- insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any);
+ insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any);
remove():Grid;
removeColumn(...options: any[]): Grid;
- removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any);
+ removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any);
render():Grid;
}
diff --git a/giraffe/giraffe-tests.ts b/giraffe/giraffe-tests.ts
index 70365bb59b..4cd6694da2 100644
--- a/giraffe/giraffe-tests.ts
+++ b/giraffe/giraffe-tests.ts
@@ -3,13 +3,13 @@
class User extends Giraffe.Model {
}
-class MainView extends Giraffe.View {
+class MainView extends Giraffe.View {
constructor(options?) {
this.appEvents = {
'startup': 'app_onStartup'
- }
- super(options)
+ }
+ super(options);
}
app_onStartup() {
@@ -23,15 +23,15 @@ class MyApp extends Giraffe.App {
this.routes= {
'': 'home'
}
- super()
+ super();
}
home() {
- this.attach( new MainView )
+ this.attach(new MainView);
}
}
var app= new MyApp();
-app.start();
\ No newline at end of file
+app.start();
diff --git a/giraffe/giraffe.d.ts b/giraffe/giraffe.d.ts
index 24c41aa243..9987548980 100644
--- a/giraffe/giraffe.d.ts
+++ b/giraffe/giraffe.d.ts
@@ -38,8 +38,8 @@ declare module Giraffe {
interface AppMap {
[ cid:string ]: App;
}
- interface ViewMap {
- [ cid:string ]: View;
+ interface ViewMap {
+ [ cid:string ]: View;
}
interface StringMap {
[ def:string ]: string;
@@ -49,7 +49,7 @@ declare module Giraffe {
var apps: AppMap;
var defaultOptions: DefaultOptions;
var version: string;
- var views: ViewMap;
+ var views: ViewMap;
function bindAppEvents( instance:GiraffeObject ): GiraffeObject;
function bindDataEvents( instance:GiraffeObject ): GiraffeObject;
@@ -64,9 +64,10 @@ declare module Giraffe {
function wrapFn( obj:any, name:string, before:Function, after:Function);
- class Collection extends Backbone.Collection implements GiraffeObject {
+ class Collection extends Backbone.Collection implements GiraffeObject {
app: App;
- model: Model;
+ //model: typeof TModel;
+ model: { new (): TModel; }; // workaround
}
class Model extends Backbone.Model implements GiraffeObject {
@@ -85,46 +86,46 @@ declare module Giraffe {
reload( url:string );
}
- class View extends Backbone.View implements GiraffeObject {
+ class View extends Backbone.View implements GiraffeObject {
app: App;
appEvents: StringMap;
- children: View[];
+ children: View[];
dataEvents: StringMap;
defaultOptions: DefaultOptions;
documentTitle: string;
- parent: View;
+ parent: View;
template: any;
ui: StringMap;
- attachTo( el:any, options?:AttachmentOptions ): View;
- attach( view:View, options?:AttachmentOptions ): View;
+ attachTo( el:any, options?:AttachmentOptions ): View;
+ attach( view:View, options?:AttachmentOptions ): View;
isAttached( el:any ): boolean;
- render( options?:any ): View;
+ render( options?:any ): View;
beforeRender();
afterRender();
templateStrategy(): string;
serialize(): any;
- setParent( parent:View ): View;
+ setParent( parent:View ): View;
- addChild( child:View ): View;
- addChildren( children:View[] ): View;
- removeChild( child:View, preserve?:boolean ): View;
- removeChildren( preserve?:boolean ): View;
+ addChild( child:View ): View;
+ addChildren( children:View[] ): View;
+ removeChild( child:View, preserve?:boolean ): View;
+ removeChildren( preserve?:boolean ): View;
- detach( preserve?:boolean ): View;
- detachChildren( preserve?:boolean ): View;
+ detach( preserve?:boolean ): View;
+ detachChildren( preserve?:boolean ): View;
invoke( method:string, ...args:any[] );
- dispose(): View;
- beforeDispose(): View;
- afterDispose(): View;
+ dispose(): View;
+ beforeDispose(): View;
+ afterDispose(): View;
- static detachByElement( el:any, preserve?:boolean ): View;
- static getClosestView( el:any ): View;
- static getByCid( cid:string ): View;
+ static detachByElement( el:any, preserve?:boolean ): View;
+ static getClosestView( el:any ): View;
+ static getByCid( cid:string ): View;
static to$El( el:any, parent?:any, allowParentMatch?:boolean ): JQuery;
static setDocumentEvents( events:string[], prefix?:string ): string[];
static removeDocumentEvents( prefix?:string );
@@ -132,7 +133,7 @@ declare module Giraffe {
static setTemplateStrategy( strategy:any, instance?:any );
}
- class App extends View {
+ class App extends View {
routes: StringMap;
addInitializer( initializer:( options?:any, callback?:()=>void )=>void ): App;
@@ -146,23 +147,23 @@ declare module Giraffe {
app: App;
}
- class CollectionView extends View {
+ class CollectionView extends View {
- collection: Collection;
- modelView: View;
+ collection: Collection;
+ modelView: View;
modelViewArgs: any[];
modelViewEl: any;
renderOnChange: boolean;
- findByModel( model:Model ): View;
- addOne( model:Model ): View;
- removeOne( model:Model ): View;
+ findByModel( model:Model ): View;
+ addOne( model:Model ): View;
+ removeOne( model:Model ): View;
static getDefaults( ctx:any ): any;
}
- class FastCollectionView extends View {
- collection: Collection;
+ class FastCollectionView extends View {
+ collection: Collection;
modelTemplate: any;
modelTemplateStrategy: string;
modelEl: any;
@@ -170,11 +171,11 @@ declare module Giraffe {
modelSerialize(): any;
- addAll(): View;
- addOne( model:Model ): View;
- removeOne( model:Model ): View;
+ addAll(): View;
+ addOne( model:Model ): View;
+ removeOne( model:Model ): View;
- removeByIndex( index:number ): View;
+ removeByIndex( index:number ): View;
findElByModel( model:Model ): JQuery;
findElByIndex( index:number ): JQuery;
findModelByEl( el:any ): Model;
diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts
index f4e0926ea7..c2ff9c1c75 100644
--- a/jointjs/jointjs.d.ts
+++ b/jointjs/jointjs.d.ts
@@ -38,20 +38,19 @@ declare module joint {
attr(attrs: any): Cell;
}
-
-
class Element extends Cell {
position(x: number, y: number): Element;
translate(tx: number, ty?: number): Element;
resize(width: number, height: number): Element;
rotate(angle: number, absolute): Element;
}
+
interface IDefaults {
type: string;
}
class Link extends Cell {
- defaults: IDefaults;
+ defaults(): IDefaults;
disconnect(): Link;
label(idx?: number, value?: any): any; // @todo: returns either a label under idx or Link if both idx and value were passed
}
@@ -65,7 +64,7 @@ declare module joint {
linkView: LinkView;
}
- class Paper extends Backbone.View {
+ class Paper extends Backbone.View {
options: IOptions;
setDimensions(width: number, height: number);
scale(sx: number, sy?: number, ox?: number, oy?: number): Paper;
@@ -80,7 +79,8 @@ declare module joint {
class ElementView extends CellView {
scale(sx: number, sy: number);
}
- class CellView extends Backbone.View {
+
+ class CellView extends Backbone.View| {
getBBox(): { x: number; y: number; width: number; height: number; };
highlight(el?: any);
unhighlight(el?: any);
@@ -94,7 +94,9 @@ declare module joint {
}
}
+
module ui { }
+
module shapes {
module basic {
class Generic extends joint.dia.Element { }
@@ -104,6 +106,7 @@ declare module joint {
class Image extends Generic { }
}
}
+
module util {
function uuid(): string;
function guid(obj: any): string;
@@ -112,4 +115,5 @@ declare module joint {
function deepMixin(objects: any[]): any;
function deepSupplement(objects: any[], defaultIndicator?: any): any;
}
+
}
diff --git a/knockback/knockback.d.ts b/knockback/knockback.d.ts
index 50848e6841..71773ab92b 100644
--- a/knockback/knockback.d.ts
+++ b/knockback/knockback.d.ts
@@ -126,8 +126,8 @@ declare module Knockback {
}
interface CollectionObservable extends KnockoutObservableArray {
- collection(colleciton: Backbone.Collection);
- collection(): Backbone.Collection;
+ collection(colleciton: Backbone.Collection);
+ collection(): Backbone.Collection;
destroy();
shareOptions(): CollectionOptions;
filters(id: any) : Backbone.Model;
@@ -163,7 +163,7 @@ declare module Knockback {
}
interface Static extends Utils {
- collectionObservable(model?: Backbone.Collection, options?: CollectionOptions): CollectionObservable;
+ collectionObservable(model?: Backbone.Collection, options?: CollectionOptions): CollectionObservable;
/** Base class for observing model attributes. */
observable(
/** the model to observe (can be null) */
diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts
index 0e501f6f8a..7a52d7453c 100644
--- a/marionette/marionette.d.ts
+++ b/marionette/marionette.d.ts
@@ -11,49 +11,49 @@
declare module Backbone {
// Backbone.BabySitter
- class ChildViewContainer {
+ class ChildViewContainer {
constructor(initialViews?: any[]);
- add(view: View, customIndex?: number);
- findByModel(model): View;
- findByModelCid(modelCid): View;
- findByCustom(index: number): View;
- findByIndex(index: number): View;
- findByCid(cid): View;
- remove(view: View);
+ add(view: View, customIndex?: number);
+ findByModel(model): View;
+ findByModelCid(modelCid): View;
+ findByCustom(index: number): View;
+ findByIndex(index: number): View;
+ findByCid(cid): View;
+ remove(view: View);
call(method);
apply(method: any, args?: any[]);
//mixins from Collection (copied from Backbone's Collection declaration)
- all(iterator: (element: View, index: number) => boolean, context?: any): boolean;
- any(iterator: (element: View, index: number) => boolean, context?: any): boolean;
+ all(iterator: (element: View, index: number) => boolean, context?: any): boolean;
+ any(iterator: (element: View, index: number) => boolean, context?: any): boolean;
contains(value: any): boolean;
detect(iterator: (item: any) => boolean, context?: any): any;
- each(iterator: (element: View, index: number, list?: any) => void , context?: any);
- every(iterator: (element: View, index: number) => boolean, context?: any): boolean;
- filter(iterator: (element: View, index: number) => boolean, context?: any): View[];
- find(iterator: (element: View, index: number) => boolean, context?: any): View;
- first(): View;
- forEach(iterator: (element: View, index: number, list?: any) => void , context?: any);
+ each(iterator: (element: View, index: number, list?: any) => void , context?: any);
+ every(iterator: (element: View, index: number) => boolean, context?: any): boolean;
+ filter(iterator: (element: View, index: number) => boolean, context?: any): View[];
+ find(iterator: (element: View, index: number) => boolean, context?: any): View;
+ first(): View;
+ forEach(iterator: (element: View, index: number, list?: any) => void , context?: any);
include(value: any): boolean;
- initial(): View;
- initial(n: number): View[];
+ initial(): View;
+ initial(n: number): View[];
invoke(methodName: string, arguments?: any[]);
isEmpty(object: any): boolean;
- last(): View;
- last(n: number): View[];
- lastIndexOf(element: View, fromIndex?: number): number;
- map(iterator: (element: View, index: number, context?: any) => any[], context?: any): any[];
+ last(): View;
+ last(n: number): View[];
+ lastIndexOf(element: View, fromIndex?: number): number;
+ map(iterator: (element: View, index: number, context?: any) => any[], context?: any): any[];
pluck(attribute: string): any[];
- reject(iterator: (element: View, index: number) => boolean, context?: any): View[];
- rest(): View;
- rest(n: number): View[];
+ reject(iterator: (element: View, index: number) => boolean, context?: any): View[];
+ rest(): View;
+ rest(n: number): View[];
select(iterator: any, context?: any): any[];
- some(iterator: (element: View, index: number) => boolean, context?: any): boolean;
+ some(iterator: (element: View, index: number) => boolean, context?: any): boolean;
toArray(): any[];
- without(...values: any[]): View[];
+ without(...values: any[]): View[];
}
// Backbone.Wreqr
@@ -107,7 +107,7 @@ declare module Marionette {
function getOption(target, optionName): any;
function triggerMethod(name, ...args: any[]): any;
- function MonitorDOMRefresh(view: Backbone.View): void;
+ function MonitorDOMRefresh(view: Backbone.View): void;
function bindEntityEvents(target, entity, bindings);
function unbindEntityEvents(target, entity, bindings);
@@ -121,24 +121,24 @@ declare module Marionette {
close();
}
- class Region extends Backbone.Events {
+ class Region extends Backbone.Events {
- static buildRegion(regionConfig, defaultRegionType): Region;
+ static buildRegion(regionConfig, defaultRegionType): Region;
el: any;
- show(view: Backbone.View): void;
+ show(view: Backbone.View): void;
ensureEl(): void;
- open(view: Backbone.View): void;
+ open(view: Backbone.View): void;
close(): void;
- attachView(view: Backbone.View);
+ attachView(view: Backbone.View);
reset();
}
- class RegionManager extends Controller {
+ class RegionManager extends Controller {
addRegions(regionDefinitions, defaults?): any;
- addRegion(name, definition): Region;
- get (name: string): Region;
+ addRegion(name, definition): Region;
+ get(name: string): Region;
removeRegion(name): void;
removeRegions(): void;
closeRegions(): void;
@@ -146,33 +146,33 @@ declare module Marionette {
//mixins from Collection (copied from Backbone's Collection declaration)
- all(iterator: (element: Region, index: number) => boolean, context?: any): boolean;
- any(iterator: (element: Region, index: number) => boolean, context?: any): boolean;
+ all(iterator: (element: Region, index: number) => boolean, context?: any): boolean;
+ any(iterator: (element: Region, index: number) => boolean, context?: any): boolean;
contains(value: any): boolean;
detect(iterator: (item: any) => boolean, context?: any): any;
- each(iterator: (element: Region, index: number, list?: any) => void , context?: any);
- every(iterator: (element: Region, index: number) => boolean, context?: any): boolean;
- filter(iterator: (element: Region, index: number) => boolean, context?: any): Region[];
- find(iterator: (element: Region, index: number) => boolean, context?: any): Region;
- first(): Region;
- forEach(iterator: (element: Region, index: number, list?: any) => void , context?: any);
+ each(iterator: (element: Region, index: number, list?: any) => void , context?: any);
+ every(iterator: (element: Region, index: number) => boolean, context?: any): boolean;
+ filter(iterator: (element: Region, index: number) => boolean, context?: any): Region[];
+ find(iterator: (element: Region, index: number) => boolean, context?: any): Region;
+ first(): Region;
+ forEach(iterator: (element: Region, index: number, list?: any) => void , context?: any);
include(value: any): boolean;
- initial(): Region;
- initial(n: number): Region[];
+ initial(): Region;
+ initial(n: number): Region[];
invoke(methodName: string, arguments?: any[]);
isEmpty(object: any): boolean;
- last(): Region;
- last(n: number): Region[];
- lastIndexOf(element: Region, fromIndex?: number): number;
- map(iterator: (element: Region, index: number, context?: any) => any[], context?: any): any[];
+ last(): Region;
+ last(n: number): Region[];
+ lastIndexOf(element: Region, fromIndex?: number): number;
+ map(iterator: (element: Region, index: number, context?: any) => any[], context?: any): any[];
pluck(attribute: string): any[];
- reject(iterator: (element: Region, index: number) => boolean, context?: any): Region[];
- rest(): Region;
- rest(n: number): Region[];
+ reject(iterator: (element: Region, index: number) => boolean, context?: any): Region[];
+ rest(): Region;
+ rest(n: number): Region[];
select(iterator: any, context?: any): any[];
- some(iterator: (element: Region, index: number) => boolean, context?: any): boolean;
+ some(iterator: (element: Region, index: number) => boolean, context?: any): boolean;
toArray(): any[];
- without(...values: any[]): Region[];
+ without(...values: any[]): Region[];
}
class TemplateCache {
@@ -187,7 +187,7 @@ declare module Marionette {
static render(template, data): void;
}
- class View extends Backbone.View {
+ class View extends Backbone.View {
constructor(options?: any);
@@ -208,72 +208,72 @@ declare module Marionette {
triggerMethod(name, ...args: any[]): any;
}
- class ItemView extends View {
+ class ItemView extends View {
constructor(options?: any);
ui: any;
serializeData(): any;
- render(): ItemView;
+ render(): ItemView;
close();
}
- class CollectionView extends View {
+ class CollectionView extends View {
constructor(options?: any);
itemView: any;
children: any;
//_initialEvents();
- addChildView(item: View, collection: View, options?: any);
+ addChildView(item: View, collection: View, options?: any);
onShowCalled();
triggerBeforeRender();
triggerRendered();
- render(): CollectionView;
+ render(): CollectionView;
- getItemView(item: any): ItemView;
- addItemView(item: any, ItemView: ItemView, index: Number);
- addChildViewEventForwarding(view: View);
- renderItemView(view: View, index: Number);
+ getItemView(item: any): ItemView;
+ addItemView(item: any, ItemView: ItemView, index: Number);
+ addChildViewEventForwarding(view: View);
+ renderItemView(view: View, index: Number);
buildItemView(item: any, ItemViewType: any, itemViewOptions: any): any;
removeItemView(item: any);
- removeChildView(view: View);
+ removeChildView(view: View);
checkEmpty();
- appendHtml(collectionView: View, itemView: View, index: Number);
+ appendHtml(collectionView: View, itemView: View, index: Number);
close();
closeChildren();
}
- class CompositeView extends CollectionView {
+ class CompositeView extends CollectionView {
constructor(options?: any);
itemView: any;
itemViewContainer: string;
- render(): CompositeView;
+ render(): CompositeView;
appendHtml(cv: any, iv: any);
renderModel(): any;
}
- class Layout extends ItemView {
+ class Layout extends ItemView {
constructor(options?: any);
- addRegion(name: string, definition: any): Region;
+ addRegion(name: string, definition: any): Region;
addRegions(regions: any): any;
- render(): Layout;
+ render(): Layout;
removeRegion(name: string);
}
interface AppRouterOptions extends Backbone.RouterOptions {
- appRoutes: any;
- controller: any;
+ appRoutes: any;
+ controller: any;
}
class AppRouter extends Backbone.Router {
@@ -284,7 +284,7 @@ declare module Marionette {
}
- class Application extends Backbone.Events {
+ class Application extends Backbone.Events {
vent: Backbone.Wreqr.EventAggregator;
commands: Backbone.Wreqr.Commands;
@@ -297,15 +297,15 @@ declare module Marionette {
start(options?);
addRegions(regions);
closeRegions(): void;
- removeRegion(region: Region);
- getRegion(regionName: string): Region;
+ removeRegion(region: Region);
+ getRegion(regionName: string): Region;
module(moduleNames, moduleDefinition);
}
// modules mapped for convenience, but you should probably use TypeScript modules instead
- class Module extends Backbone.Events {
+ class Module extends Backbone.Events {
- constructor(moduleName: string, app: Application);
+ constructor(moduleName: string, app: Application);
submodules: any;
triggerMethod(name, ...args: any[]): any;
@@ -319,7 +319,7 @@ declare module Marionette {
}
declare module 'backbone.marionette' {
- import Backbone = require('backbone');
-
- export = Marionette;
+ import Backbone = require('backbone');
+
+ export = Marionette;
}
|