diff --git a/backbone/backbone-global.d.ts b/backbone/backbone-global.d.ts index 734ba1b94..ae111aea0 100644 --- a/backbone/backbone-global.d.ts +++ b/backbone/backbone-global.d.ts @@ -65,8 +65,21 @@ declare module Backbone { reset?: boolean; } + interface ObjectHash { + [key: string]: any; + } + + interface RoutesHash { + [routePattern: string]: string | {(...urlParts: string[]): void}; + } + + interface EventsHash { + [selector: string]: string | {(eventObject: JQueryEventObject): void}; + } + class Events { on(eventName: string, callback?: Function, context?: any): any; + on(eventMap: EventsHash): any; off(eventName?: string, callback?: Function, context?: any): any; trigger(eventName: string, ...args: any[]): any; bind(eventName: string, callback: Function, context?: any): any; @@ -102,7 +115,7 @@ declare module Backbone { * 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; + defaults(): ObjectHash; id: any; idAttribute: string; validationError: any; @@ -272,7 +285,7 @@ declare module Backbone { * 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; + routes: RoutesHash | any; constructor(options?: RouterOptions); initialize(options?: RouterOptions): void; @@ -310,7 +323,7 @@ declare module Backbone { interface ViewOptions { model?: TModel; // TODO: quickfix, this can't be fixed easy. The collection does not need to have the same model as the parent view. - collection?: Backbone.Collection; + collection?: Backbone.Collection; //was: Collection; el?: any; id?: string; className?: string; @@ -333,7 +346,7 @@ declare module Backbone { * 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; + events(): EventsHash; $(selector: string): JQuery; model: TModel; @@ -353,7 +366,7 @@ declare module Backbone { render(): View; remove(): View; make(tagName: any, attributes?: any, content?: any): any; - delegateEvents(events?: any): any; + delegateEvents(events?: EventsHash): any; undelegateEvents(): any; _ensureElement(): void;