mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Merge pull request #41 from docgit/master
Fixes in Backbone, Knockback and Knockout
This commit is contained in:
68
Definitions/backbone-0.9.d.ts
vendored
68
Definitions/backbone-0.9.d.ts
vendored
@@ -11,11 +11,11 @@ declare module Backbone {
|
||||
export interface AddOptions extends Silenceable {
|
||||
at: number;
|
||||
}
|
||||
|
||||
|
||||
export interface CreateOptions extends Silenceable {
|
||||
wait: bool;
|
||||
}
|
||||
|
||||
|
||||
export interface HistoryOptions extends Silenceable {
|
||||
pushState: bool;
|
||||
root: string;
|
||||
@@ -33,16 +33,18 @@ declare module Backbone {
|
||||
silent: bool;
|
||||
}
|
||||
|
||||
interface EventCallback {
|
||||
(event): void;
|
||||
}
|
||||
interface on { (eventName: string, callback: (...args: any[]) => void, context?: any): any; }
|
||||
interface off { (eventName?: string, callback?: (...args: any[]) => void, context?: any): any; }
|
||||
interface trigger { (eventName: string, ...args: any[]): any; }
|
||||
interface bind { (eventName: string, callback: (...args: any[]) => void, context?: any): any; }
|
||||
interface unbind { (eventName?: string, callback?: (...args: any[]) => void, context?: any): any; }
|
||||
|
||||
export class Events {
|
||||
on(eventName: string, callback: EventCallback, context?: any): any;
|
||||
bind(eventName: string, callback: EventCallback, context?: any): any;
|
||||
off(eventName?: string, callback?: EventCallback, context?: any): any;
|
||||
unbind(eventName?: string, callback?: EventCallback, context?: any): any;
|
||||
declare class Events {
|
||||
on(eventName: string, callback: (...args:any[]) => void, context?: any): any;
|
||||
off(eventName?: string, callback?: (...args:any[]) => void, context?: any): any;
|
||||
trigger(eventName: string, ...args: any[]): any;
|
||||
bind(eventName: string, callback: (...args:any[]) => void, context?: any): any;
|
||||
unbind(eventName?: string, callback?: (...args:any[]) => void, context?: any): any;
|
||||
}
|
||||
|
||||
export class ModelBase extends Events {
|
||||
@@ -75,7 +77,7 @@ declare module Backbone {
|
||||
changedAttributes(attributes?: any): any[];
|
||||
clear(options?: Silenceable);
|
||||
clone(): Model;
|
||||
destroy(options?: JQueryAjaxSettings): any; // jqXHR or false
|
||||
destroy(options?: JQueryAjaxSettings);
|
||||
escape(attribute: string);
|
||||
has(attribute: string): bool;
|
||||
hasChanged(attribute?: string): bool;
|
||||
@@ -83,8 +85,8 @@ declare module Backbone {
|
||||
isValid(): string;
|
||||
previous(attribute: string): any;
|
||||
previousAttributes(): any[];
|
||||
save(attributes?: any, options?: JQueryAjaxSettings): any; // JQueryXHR or false
|
||||
unset(attribute: string, options?: Silenceable): any;
|
||||
save(attributes?: any, options?: JQueryAjaxSettings);
|
||||
unset(attribute: string, options?: Silenceable);
|
||||
validate(attributes: any): any;
|
||||
}
|
||||
|
||||
@@ -97,7 +99,7 @@ declare module Backbone {
|
||||
collection: Model;
|
||||
length: number;
|
||||
|
||||
constructor (models?: any, options? );
|
||||
constructor (models?: any, options?: any);
|
||||
|
||||
add(model: Model, options?: AddOptions);
|
||||
add(models: Model[], options?: AddOptions);
|
||||
@@ -108,11 +110,11 @@ declare module Backbone {
|
||||
getByCid(cid): Model;
|
||||
create(attributes: any, options?: CreateOptions): Collection;
|
||||
pluck(attribute: string): any[];
|
||||
push(model: Model, options?: AddOptions): Model;
|
||||
push(model: Model, options?: AddOptions);
|
||||
pop(options?: Silenceable);
|
||||
remove(model: Model, options?: Silenceable);
|
||||
remove(models: Model[], options?: Silenceable);
|
||||
reset(models?: Model[], options? );
|
||||
reset(models?: Model[], options?: Silenceable);
|
||||
shift(options?: Silenceable);
|
||||
sort(options?: Silenceable);
|
||||
unshift(model: Model, options?: AddOptions);
|
||||
@@ -129,15 +131,15 @@ declare module Backbone {
|
||||
difference(...model: Model[]): Model[];
|
||||
drop(): Model;
|
||||
drop(n: number): Model[];
|
||||
each(iterator: (element: Model, index: number, list? ) => void , context?: any);
|
||||
each(iterator: (element: Model, index: number, list?: any) => void, context?: any);
|
||||
every(iterator: (element: Model, index: number) => bool, context?: any): bool;
|
||||
filter(iterator: (elemebt: Model, index: number) => bool, context?: any): Model[];
|
||||
filter(iterator: (element: Model, index: number) => bool, context?: any): Model[];
|
||||
find(iterator: (element: Model, index: number) => bool, context?: any): Model;
|
||||
first(): Model;
|
||||
first(n: number): Model[];
|
||||
flatten(shallow?: bool): Model[];
|
||||
foldl(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any;
|
||||
forEach(iterator: (element: Model, index: number, list? ) => void , context?: any);
|
||||
forEach(iterator: (element: Model, index: number, list?: any) => void, context?: any);
|
||||
groupBy(iterator: (element: Model, index: number) => any): any[];
|
||||
groupBy(attribute: string): any[];
|
||||
include(value: any): bool;
|
||||
@@ -185,8 +187,8 @@ declare module Backbone {
|
||||
routes: any;
|
||||
|
||||
constructor (options?: RouterOptions);
|
||||
initialize(options?: RouterOptions);
|
||||
route(route: string, name: string, callback?: (...parameter: any[]) => void );
|
||||
initialize (options?: RouterOptions);
|
||||
route(route: string, name: string, callback?: (...parameter: any[]) => void);
|
||||
navigate(fragment: string, options?: NavigateOptions);
|
||||
}
|
||||
|
||||
@@ -197,15 +199,25 @@ declare module Backbone {
|
||||
pushSate();
|
||||
}
|
||||
|
||||
export class View {
|
||||
export interface ViewOptions {
|
||||
model?: Backbone.Model;
|
||||
collection?: Backbone.Collection;
|
||||
el?: Element;
|
||||
id?: string;
|
||||
className?: string;
|
||||
tagName?: string;
|
||||
attributes?: any[];
|
||||
}
|
||||
|
||||
export class View extends Events {
|
||||
|
||||
static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
|
||||
|
||||
constructor (options?: any);
|
||||
constructor (options?: ViewOptions);
|
||||
|
||||
$(selector: string): any;
|
||||
model: Model;
|
||||
make(tagName: string, attrs? , opts? ): View;
|
||||
make(tagName: string, attrs?, opts?): View;
|
||||
setElement(element: HTMLElement, delegate?: bool);
|
||||
tagName: string;
|
||||
events: any;
|
||||
@@ -217,7 +229,7 @@ declare module Backbone {
|
||||
$(selector);
|
||||
render();
|
||||
remove();
|
||||
make(tagName, attributes? , content? );
|
||||
make(tagName, attributes?, content?);
|
||||
//delegateEvents: any;
|
||||
delegateEvents(events?: any): any;
|
||||
undelegateEvents();
|
||||
@@ -225,10 +237,10 @@ declare module Backbone {
|
||||
|
||||
// SYNC
|
||||
function sync(method, model, options?: JQueryAjaxSettings);
|
||||
var emulateHTTP: bool;
|
||||
var emulateJSONBackbone: bool;
|
||||
var emulateHTTP: bool;
|
||||
var emulateJSONBackbone: bool;
|
||||
|
||||
// Utility
|
||||
function noConflict(): Backbone;
|
||||
function setDomLibrary(jQueryNew);
|
||||
}
|
||||
}
|
||||
|
||||
72
Definitions/knockback-0.16.d.ts
vendored
72
Definitions/knockback-0.16.d.ts
vendored
@@ -1,17 +1,11 @@
|
||||
// Type definitions for knockback.js 0.16
|
||||
// Project: http://backbonejs.org/
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference path="backbone-0.9.d.ts" />
|
||||
/// <reference path="backbone-0.9.d.ts" />
|
||||
/// <reference path="knockout-2.2.d.ts" />
|
||||
|
||||
declare module Knockback {
|
||||
export interface EventWatcherOptions {
|
||||
emitter : (newEmitter) => void;
|
||||
update : (newValue) => void;
|
||||
event_selector : string;
|
||||
key? : string;
|
||||
emitter: (newEmitter) => void;
|
||||
update: (newValue) => void;
|
||||
event_selector: string;
|
||||
key?: string;
|
||||
}
|
||||
|
||||
export interface FactoryOptions {
|
||||
@@ -30,33 +24,36 @@ declare module Knockback {
|
||||
}
|
||||
|
||||
export class ViewModel extends Destroyable {
|
||||
constructor (model? : Backbone.Model , options? : ViewModelOptions, viewModel? : ViewModel );
|
||||
shareOptions() : ViewModelOptions;
|
||||
constructor (model?: Backbone.Model, options?: ViewModelOptions, viewModel?: ViewModel);
|
||||
shareOptions(): ViewModelOptions;
|
||||
extend(source: any);
|
||||
model(): Backbone.Model;
|
||||
}
|
||||
|
||||
export class EventWatcher extends Destroyable {
|
||||
useOptionsOrCreate(options, emitter : KnockoutObservableAny, obj : Backbone.Model, callback_options : any);
|
||||
static useOptionsOrCreate(options, emitter: KnockoutObservableAny, obj: Backbone.Model, callback_options: any);
|
||||
|
||||
emitter(): Backbone.Model;
|
||||
emitter(newEmitter : Backbone.Model);
|
||||
emitter(newEmitter: Backbone.Model);
|
||||
registerCallbacks(obj: any, callback_info: any);
|
||||
releaseCallbacks(obj: any);
|
||||
}
|
||||
|
||||
export class Factory {
|
||||
constructor (parent_factory : any);
|
||||
useOptionsOrCreate(options: FactoryOptions, obj: any, owner_path: string);
|
||||
static useOptionsOrCreate(options: FactoryOptions, obj: any, owner_path: string);
|
||||
|
||||
constructor (parent_factory: any);
|
||||
hasPath(path: string): bool;
|
||||
addPathMapping(path: string, create_info);
|
||||
addPathMappings(factories: any, owner_path: string);
|
||||
hasPathMappings(factories: any, owner_path: string) : bool;
|
||||
hasPathMappings(factories: any, owner_path: string): bool;
|
||||
creatorForPath(obj: any, path: string);
|
||||
}
|
||||
|
||||
export class Store extends Destroyable {
|
||||
static useOptionsOrCreate(options: StoreOptions, obj: any, observable: KnockoutObservableAny);
|
||||
|
||||
constructor (model:Backbone.Model, options: StoreOptions);
|
||||
useOptionsOrCreate(options: StoreOptions, obj: any, observable: KnockoutObservableAny);
|
||||
clear();
|
||||
register(obj: Backbone.Model, observable: KnockoutObservableAny, options: StoreOptions);
|
||||
findOrCreate(obj: Backbone.Model, options: StoreOptions);
|
||||
@@ -81,7 +78,7 @@ declare module Knockback {
|
||||
|
||||
export class TriggeredObservable extends Destroyable {
|
||||
constructor (emitter: Backbone.ModelBase, event: string);
|
||||
emitter() : Backbone.ModelBase;
|
||||
emitter(): Backbone.ModelBase;
|
||||
emitter(newEmitter: Backbone.ModelBase);
|
||||
}
|
||||
|
||||
@@ -92,8 +89,8 @@ declare module Knockback {
|
||||
modelEventsStatsString();
|
||||
register(key: string, obj: any);
|
||||
unregister(key: string, obj: any);
|
||||
registeredCount(type: any) : number;
|
||||
registeredStatsString(success_message: string) : string;
|
||||
registeredCount(type: any): number;
|
||||
registeredStatsString(success_message: string): string;
|
||||
}
|
||||
|
||||
export interface OptionsBase {
|
||||
@@ -123,31 +120,32 @@ declare module Knockback {
|
||||
}
|
||||
|
||||
export interface CollectionObservable extends KnockoutObservableArray {
|
||||
collection() : Backbone.Collection;
|
||||
collection(colleciton: Backbone.Collection);
|
||||
collection(): Backbone.Collection;
|
||||
destroy();
|
||||
shareOptions() : CollectionOptions;
|
||||
shareOptions(): CollectionOptions;
|
||||
filters(filter: any);
|
||||
comparator(comparatorFunction: any);
|
||||
sortAttribute(attr: string);
|
||||
viewModelByModel(model: Backbone.Model) : ViewModel;
|
||||
viewModelByModel(model: Backbone.Model): ViewModel;
|
||||
hasViewModels(): bool;
|
||||
}
|
||||
|
||||
export interface Utils {
|
||||
wrappedObservable(obj: any) : any;
|
||||
wrappedObservable(obj: any): any;
|
||||
wrappedObservable(obj: any, value: any);
|
||||
wrappedObject(obj: any) : any;
|
||||
wrappedObject(obj: any): any;
|
||||
wrappedObject(obj: any, value: any);
|
||||
wrappedModel(obj: any) : any;
|
||||
wrappedModel(obj: any): any;
|
||||
wrappedModel(obj: any, value: any);
|
||||
wrappedStore(obj: any) : any;
|
||||
wrappedStore(obj: any): any;
|
||||
wrappedStore(obj: any, value: any);
|
||||
wrappedFactory(obj: any) : any;
|
||||
wrappedFactory(obj: any): any;
|
||||
wrappedFactory(obj: any, value: any);
|
||||
wrappedEventWatcher(obj: any) : any;
|
||||
wrappedEventWatcher(obj: any): any;
|
||||
wrappedEventWatcher(obj: any, value: any);
|
||||
wrappedDestroy(obj: any);
|
||||
valueType(observable: KnockoutObservableAny) : any;
|
||||
valueType(observable: KnockoutObservableAny): any;
|
||||
pathJoin(path1: string, path2: string): string;
|
||||
optionsPathJoin(options: any, path: string): any;
|
||||
inferCreator(value: any, factory: Factory, path: string, owner: any, key: string);
|
||||
@@ -158,13 +156,13 @@ declare module Knockback {
|
||||
|
||||
export interface Static extends Utils {
|
||||
collectionObservable(model?: Backbone.Collection, options?: CollectionOptions): CollectionObservable;
|
||||
observable(model?: Backbone.Model, options?: any) : KnockoutObservableAny;
|
||||
viewModel(model?: Backbone.Model, options?: any) : KnockoutObservableAny;
|
||||
defaultObservable(targetObservable: KnockoutObservableAny, defaultValue: any) : KnockoutObservableAny;
|
||||
formattedObservable(format: string, args: any[]) : KnockoutObservableAny;
|
||||
observable(model?: Backbone.Model, options?: any): KnockoutObservableAny;
|
||||
viewModel(model?: Backbone.Model, options?: any): KnockoutObservableAny;
|
||||
defaultObservable(targetObservable: KnockoutObservableAny, defaultValue: any): KnockoutObservableAny;
|
||||
formattedObservable(format: string, args: any[]): KnockoutObservableAny;
|
||||
formattedObservable(format: KnockoutObservableAny, args: any[]): KnockoutObservableAny;
|
||||
localizedObservable(data: any, options: any): KnockoutObservableAny;
|
||||
release(object: any, pre_release?: () => void );
|
||||
release(object: any, pre_release?: () => void);
|
||||
releaseKeys(object: any);
|
||||
releaseOnNodeRemove(viewmodel: ViewModel, node: Element);
|
||||
renderTemplate(template: string, viewModel: ViewModel, options: any);
|
||||
|
||||
3
Definitions/knockout-2.2.d.ts
vendored
3
Definitions/knockout-2.2.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Knockout 2.2
|
||||
// Type definitions for Knockout 2.2
|
||||
// Project: http://knockoutjs.com
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -267,6 +267,7 @@ interface KnockoutStatic {
|
||||
toJS(viewModel: any): any;
|
||||
isObservable(instance: any): bool;
|
||||
dataFor(node: any): any;
|
||||
removeNode(node: Element);
|
||||
}
|
||||
|
||||
declare var ko: KnockoutStatic;
|
||||
Reference in New Issue
Block a user