mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
minor fixes+typings, mostly adding documentation
angularjs: docs around first page tutorials jquery: fix for known lib.d.ts big knockback: add typing for observable based on tutorial, add docs around observable.
This commit is contained in:
1293
angularjs/angular.d.ts
vendored
1293
angularjs/angular.d.ts
vendored
File diff suppressed because it is too large
Load Diff
1580
jquery/jquery.d.ts
vendored
1580
jquery/jquery.d.ts
vendored
File diff suppressed because it is too large
Load Diff
394
knockback/knockback.d.ts
vendored
394
knockback/knockback.d.ts
vendored
@@ -1,178 +1,218 @@
|
||||
/// <reference path="../backbone/backbone.d.ts" />
|
||||
/// <reference path="../knockout/knockout.d.ts" />
|
||||
|
||||
declare module Knockback {
|
||||
export interface EventWatcherOptions {
|
||||
emitter: (newEmitter) => void;
|
||||
update: (newValue) => void;
|
||||
event_selector: string;
|
||||
key?: string;
|
||||
}
|
||||
|
||||
export interface FactoryOptions {
|
||||
factories: any;
|
||||
}
|
||||
|
||||
export interface StoreOptions {
|
||||
creator: any;
|
||||
path: string;
|
||||
store: Store;
|
||||
factory: Factory;
|
||||
}
|
||||
|
||||
export class Destroyable {
|
||||
destroy();
|
||||
}
|
||||
|
||||
export class ViewModel extends Destroyable {
|
||||
constructor (model?: Backbone.Model, options?: ViewModelOptions, viewModel?: ViewModel);
|
||||
shareOptions(): ViewModelOptions;
|
||||
extend(source: any);
|
||||
model(): Backbone.Model;
|
||||
}
|
||||
|
||||
export class EventWatcher extends Destroyable {
|
||||
static useOptionsOrCreate(options, emitter: KnockoutObservableAny, obj: Backbone.Model, callback_options: any);
|
||||
|
||||
emitter(): Backbone.Model;
|
||||
emitter(newEmitter: Backbone.Model);
|
||||
registerCallbacks(obj: any, callback_info: any);
|
||||
releaseCallbacks(obj: any);
|
||||
}
|
||||
|
||||
export class Factory {
|
||||
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;
|
||||
creatorForPath(obj: any, path: string);
|
||||
}
|
||||
|
||||
export class Store extends Destroyable {
|
||||
static useOptionsOrCreate(options: StoreOptions, obj: any, observable: KnockoutObservableAny);
|
||||
|
||||
constructor (model:Backbone.Model, options: StoreOptions);
|
||||
clear();
|
||||
register(obj: Backbone.Model, observable: KnockoutObservableAny, options: StoreOptions);
|
||||
findOrCreate(obj: Backbone.Model, options: StoreOptions);
|
||||
}
|
||||
|
||||
export class DefaultObservable extends Destroyable {
|
||||
constructor (targetObservable: KnockoutObservableAny, defaultValue: any);
|
||||
setToDefault();
|
||||
}
|
||||
|
||||
export class FormattedObservable extends Destroyable {
|
||||
constructor (format: string, args: any[]);
|
||||
constructor (format: KnockoutObservableAny, args: any[]);
|
||||
}
|
||||
|
||||
export interface LocalizedObservable {
|
||||
constructor (value: any, options: any, vm: any);
|
||||
destroy();
|
||||
resetToCurrent();
|
||||
observedValue(value: any);
|
||||
}
|
||||
|
||||
export class TriggeredObservable extends Destroyable {
|
||||
constructor (emitter: Backbone.ModelBase, event: string);
|
||||
emitter(): Backbone.ModelBase;
|
||||
emitter(newEmitter: Backbone.ModelBase);
|
||||
}
|
||||
|
||||
export class Statistics {
|
||||
constructor ();
|
||||
clear();
|
||||
addModelEvent(event: string);
|
||||
modelEventsStatsString();
|
||||
register(key: string, obj: any);
|
||||
unregister(key: string, obj: any);
|
||||
registeredCount(type: any): number;
|
||||
registeredStatsString(success_message: string): string;
|
||||
}
|
||||
|
||||
export interface OptionsBase {
|
||||
path?: string; // the path to the value (used to create related observables from the factory).
|
||||
store?: Store; // a store used to cache and share view models.
|
||||
factory?: Factory; // a factory used to create view models.
|
||||
options?: any; // a set of options merge into these options using _.defaults. Useful for extending options when deriving classes rather than merging them by hand.
|
||||
}
|
||||
|
||||
export interface ViewModelOptions extends OptionsBase {
|
||||
internals?: string[]; // an array of atttributes that should be scoped with an underscore, eg. name -> _name
|
||||
requires?: string[]; // an array of atttributes that will have kb.Observables created even if they do not exist on the Backbone.Model. Useful for binding Views that require specific observables to exist
|
||||
keys?: string[]; // restricts the keys used on a model. Useful for reducing the number of kb.Observables created from a limited set of Backbone.Model attributes
|
||||
if(objOrArray: any); // an array is supplied, excludes keys to exclude on the view model; for example, if you want to provide a custom implementation. If an Object, it provides options to the kb.Observable constructor.
|
||||
path?: string; // the path to the value (used to create related observables from the factory).
|
||||
factories?: any; // a map of dot-deliminated paths; for example {'models.name': kb.ViewModel} to either constructors or create functions. Signature: {'some.path': function(object, options)}
|
||||
}
|
||||
|
||||
export interface CollectionOptions extends OptionsBase {
|
||||
models_only?: bool; // flag for skipping the creation of view models. The collection observable will be populated with (possibly sorted) models.
|
||||
view_model?: any; // (Constructor) — the view model constructor used for models in the collection. Signature: constructor(model, options)
|
||||
create?: any; // a function used to create a view model for models in the collection. Signature: create(model, options)
|
||||
factories?: any; // a map of dot-deliminated paths; for example 'models.owner': kb.ViewModel to either constructors or create functions. Signature: 'some.path': function(object, options)
|
||||
comparator?: any; //a function that is used to sort an object. Signature: function(model_a, model_b) returns negative value for ascending, 0 for equal, and positive for descending
|
||||
sort_attribute?: string; // the name of an attribute. Default: resort on all changes to a model.
|
||||
filters?: any; // filters can be individual ids (observable or simple) or arrays of ids, functions, or arrays of functions.
|
||||
}
|
||||
|
||||
export interface CollectionObservable extends KnockoutObservableArray {
|
||||
collection(colleciton: Backbone.Collection);
|
||||
collection(): Backbone.Collection;
|
||||
destroy();
|
||||
shareOptions(): CollectionOptions;
|
||||
filters(id: any) : Backbone.Model;
|
||||
filters(ids: any[]): CollectionObservable;
|
||||
filters(iterator: (element: Backbone.Model) => bool): CollectionObservable;
|
||||
comparator(comparatorFunction: any);
|
||||
sortAttribute(attr: string);
|
||||
viewModelByModel(model: Backbone.Model): ViewModel;
|
||||
hasViewModels(): bool;
|
||||
}
|
||||
|
||||
export interface Utils {
|
||||
wrappedObservable(obj: any): any;
|
||||
wrappedObservable(obj: any, value: any);
|
||||
wrappedObject(obj: any): any;
|
||||
wrappedObject(obj: any, value: any);
|
||||
wrappedModel(obj: any): any;
|
||||
wrappedModel(obj: any, value: any);
|
||||
wrappedStore(obj: any): any;
|
||||
wrappedStore(obj: any, value: any);
|
||||
wrappedFactory(obj: any): any;
|
||||
wrappedFactory(obj: any, value: any);
|
||||
wrappedEventWatcher(obj: any): any;
|
||||
wrappedEventWatcher(obj: any, value: any);
|
||||
wrappedDestroy(obj: 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);
|
||||
createFromDefaultCreator(obj: any, options?: any);
|
||||
hasModelSignature(obj: any): bool;
|
||||
hasCollectionSignature(obj: any): bool;
|
||||
}
|
||||
|
||||
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;
|
||||
formattedObservable(format: KnockoutObservableAny, args: any[]): KnockoutObservableAny;
|
||||
localizedObservable(data: any, options: any): KnockoutObservableAny;
|
||||
release(object: any, pre_release?: () => void);
|
||||
releaseKeys(object: any);
|
||||
releaseOnNodeRemove(viewmodel: ViewModel, node: Element);
|
||||
renderTemplate(template: string, viewModel: ViewModel, options: any);
|
||||
renderAutoReleasedTemplate(template: string, viewModel: ViewModel, options: any);
|
||||
applyBindings(viewModel: ViewModel, node?: Element);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/// <reference path="../backbone/backbone.d.ts" />
|
||||
/// <reference path="../knockout/knockout.d.ts" />
|
||||
|
||||
declare module Knockback {
|
||||
export interface EventWatcherOptions {
|
||||
emitter: (newEmitter) => void;
|
||||
update: (newValue) => void;
|
||||
event_selector: string;
|
||||
key?: string;
|
||||
}
|
||||
|
||||
export interface FactoryOptions {
|
||||
factories: any;
|
||||
}
|
||||
|
||||
export interface StoreOptions {
|
||||
creator: any;
|
||||
path: string;
|
||||
store: Store;
|
||||
factory: Factory;
|
||||
}
|
||||
|
||||
export class Destroyable {
|
||||
destroy();
|
||||
}
|
||||
|
||||
export class ViewModel extends Destroyable {
|
||||
constructor (model?: Backbone.Model, options?: ViewModelOptions, viewModel?: ViewModel);
|
||||
shareOptions(): ViewModelOptions;
|
||||
extend(source: any);
|
||||
model(): Backbone.Model;
|
||||
}
|
||||
|
||||
export class EventWatcher extends Destroyable {
|
||||
static useOptionsOrCreate(options, emitter: KnockoutObservableAny, obj: Backbone.Model, callback_options: any);
|
||||
|
||||
emitter(): Backbone.Model;
|
||||
emitter(newEmitter: Backbone.Model);
|
||||
registerCallbacks(obj: any, callback_info: any);
|
||||
releaseCallbacks(obj: any);
|
||||
}
|
||||
|
||||
export class Factory {
|
||||
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;
|
||||
creatorForPath(obj: any, path: string);
|
||||
}
|
||||
|
||||
export class Store extends Destroyable {
|
||||
static useOptionsOrCreate(options: StoreOptions, obj: any, observable: KnockoutObservableAny);
|
||||
|
||||
constructor (model:Backbone.Model, options: StoreOptions);
|
||||
clear();
|
||||
register(obj: Backbone.Model, observable: KnockoutObservableAny, options: StoreOptions);
|
||||
findOrCreate(obj: Backbone.Model, options: StoreOptions);
|
||||
}
|
||||
|
||||
export class DefaultObservable extends Destroyable {
|
||||
constructor (targetObservable: KnockoutObservableAny, defaultValue: any);
|
||||
setToDefault();
|
||||
}
|
||||
|
||||
export class FormattedObservable extends Destroyable {
|
||||
constructor (format: string, args: any[]);
|
||||
constructor (format: KnockoutObservableAny, args: any[]);
|
||||
}
|
||||
|
||||
export interface LocalizedObservable {
|
||||
constructor (value: any, options: any, vm: any);
|
||||
destroy();
|
||||
resetToCurrent();
|
||||
observedValue(value: any);
|
||||
}
|
||||
|
||||
export class TriggeredObservable extends Destroyable {
|
||||
constructor (emitter: Backbone.ModelBase, event: string);
|
||||
emitter(): Backbone.ModelBase;
|
||||
emitter(newEmitter: Backbone.ModelBase);
|
||||
}
|
||||
|
||||
export class Statistics {
|
||||
constructor ();
|
||||
clear();
|
||||
addModelEvent(event: string);
|
||||
modelEventsStatsString();
|
||||
register(key: string, obj: any);
|
||||
unregister(key: string, obj: any);
|
||||
registeredCount(type: any): number;
|
||||
registeredStatsString(success_message: string): string;
|
||||
}
|
||||
|
||||
export interface OptionsBase {
|
||||
path?: string; // the path to the value (used to create related observables from the factory).
|
||||
store?: Store; // a store used to cache and share view models.
|
||||
factory?: Factory; // a factory used to create view models.
|
||||
options?: any; // a set of options merge into these options using _.defaults. Useful for extending options when deriving classes rather than merging them by hand.
|
||||
}
|
||||
|
||||
export interface ViewModelOptions extends OptionsBase {
|
||||
internals?: string[]; // an array of atttributes that should be scoped with an underscore, eg. name -> _name
|
||||
requires?: string[]; // an array of atttributes that will have kb.Observables created even if they do not exist on the Backbone.Model. Useful for binding Views that require specific observables to exist
|
||||
keys?: string[]; // restricts the keys used on a model. Useful for reducing the number of kb.Observables created from a limited set of Backbone.Model attributes
|
||||
if(objOrArray: any); // an array is supplied, excludes keys to exclude on the view model; for example, if you want to provide a custom implementation. If an Object, it provides options to the kb.Observable constructor.
|
||||
path?: string; // the path to the value (used to create related observables from the factory).
|
||||
factories?: any; // a map of dot-deliminated paths; for example {'models.name': kb.ViewModel} to either constructors or create functions. Signature: {'some.path': function(object, options)}
|
||||
}
|
||||
|
||||
export interface CollectionOptions extends OptionsBase {
|
||||
models_only?: bool; // flag for skipping the creation of view models. The collection observable will be populated with (possibly sorted) models.
|
||||
view_model?: any; // (Constructor) — the view model constructor used for models in the collection. Signature: constructor(model, options)
|
||||
create?: any; // a function used to create a view model for models in the collection. Signature: create(model, options)
|
||||
factories?: any; // a map of dot-deliminated paths; for example 'models.owner': kb.ViewModel to either constructors or create functions. Signature: 'some.path': function(object, options)
|
||||
comparator?: any; //a function that is used to sort an object. Signature: function(model_a, model_b) returns negative value for ascending, 0 for equal, and positive for descending
|
||||
sort_attribute?: string; // the name of an attribute. Default: resort on all changes to a model.
|
||||
filters?: any; // filters can be individual ids (observable or simple) or arrays of ids, functions, or arrays of functions.
|
||||
}
|
||||
|
||||
export interface CollectionObservable extends KnockoutObservableArray {
|
||||
collection(colleciton: Backbone.Collection);
|
||||
collection(): Backbone.Collection;
|
||||
destroy();
|
||||
shareOptions(): CollectionOptions;
|
||||
filters(id: any) : Backbone.Model;
|
||||
filters(ids: any[]): CollectionObservable;
|
||||
filters(iterator: (element: Backbone.Model) => bool): CollectionObservable;
|
||||
comparator(comparatorFunction: any);
|
||||
sortAttribute(attr: string);
|
||||
viewModelByModel(model: Backbone.Model): ViewModel;
|
||||
hasViewModels(): bool;
|
||||
}
|
||||
|
||||
export interface Utils {
|
||||
wrappedObservable(obj: any): any;
|
||||
wrappedObservable(obj: any, value: any);
|
||||
wrappedObject(obj: any): any;
|
||||
wrappedObject(obj: any, value: any);
|
||||
wrappedModel(obj: any): any;
|
||||
wrappedModel(obj: any, value: any);
|
||||
wrappedStore(obj: any): any;
|
||||
wrappedStore(obj: any, value: any);
|
||||
wrappedFactory(obj: any): any;
|
||||
wrappedFactory(obj: any, value: any);
|
||||
wrappedEventWatcher(obj: any): any;
|
||||
wrappedEventWatcher(obj: any, value: any);
|
||||
wrappedDestroy(obj: 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);
|
||||
createFromDefaultCreator(obj: any, options?: any);
|
||||
hasModelSignature(obj: any): bool;
|
||||
hasCollectionSignature(obj: any): bool;
|
||||
}
|
||||
|
||||
export interface Static extends Utils {
|
||||
collectionObservable(model?: Backbone.Collection, options?: CollectionOptions): CollectionObservable;
|
||||
/** Base class for observing model attributes. */
|
||||
observable(
|
||||
/** the model to observe (can be null) */
|
||||
model: Backbone.Model,
|
||||
/** the create options. String is a single attribute name, Array is an array of attribute names. */
|
||||
options: IObservableOptions,
|
||||
/** the viewModel */
|
||||
vm?: ViewModel): KnockoutObservableAny;
|
||||
observable(
|
||||
/** the model to observe (can be null) */
|
||||
model: Backbone.Model,
|
||||
/** the create options. String is a single attribute name, Array is an array of attribute names. */
|
||||
options_attributeName: string,
|
||||
/** the viewModel */
|
||||
vm?: ViewModel): 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 );
|
||||
releaseKeys(object: any);
|
||||
releaseOnNodeRemove(viewmodel: ViewModel, node: Element);
|
||||
renderTemplate(template: string, viewModel: ViewModel, options: any);
|
||||
renderAutoReleasedTemplate(template: string, viewModel: ViewModel, options: any);
|
||||
applyBindings(viewModel: ViewModel, node?: Element);
|
||||
}
|
||||
|
||||
/** parameter of ko.observable constructor
|
||||
Options Hash: (option):
|
||||
key (String) — the name of the attribute.
|
||||
read (Function) — a function used to provide transform the attribute value before passing it to the caller. Signature: read()
|
||||
write (Function) — a function used to provide transform the value before passing it to the model set function. Signature: write(value)
|
||||
args (Array) — arguments to pass to the read and write functions (they can be ko.observables). Can be useful for passing arguments to a locale manager.
|
||||
localizer (Constructor) — a concrete kb.LocalizedObservable constructor for localization.
|
||||
default (Data|ko.observable) — the default value. Can be a value, string or ko.observable.
|
||||
path (String) — the path to the value (used to create related observables from the factory).
|
||||
store (kb.Store) — a store used to cache and share view models.
|
||||
factory (kb.Factory) — a factory used to create view models.
|
||||
options (Object) — a set of options merge into these options using _.defaults. Useful for extending options when deriving classes rather than merging them by hand.
|
||||
*/
|
||||
interface IObservableOptions {
|
||||
key: string;
|
||||
read?: () => any;
|
||||
write?: (value: any) => void;
|
||||
args?: KnockoutObservableAny[];
|
||||
localizer?: LocalizedObservable;
|
||||
default?: any;
|
||||
path?: string;
|
||||
store?: any;
|
||||
factory?: any;
|
||||
options?: any;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
declare var kb: Knockback.Static;
|
||||
614
knockout/knockout.d.ts
vendored
614
knockout/knockout.d.ts
vendored
@@ -1,306 +1,310 @@
|
||||
// Type definitions for Knockout 2.2
|
||||
// Project: http://knockoutjs.com
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
interface KnockoutSubscribableFunctions {
|
||||
extend(source);
|
||||
dispose(): void;
|
||||
peek(): any;
|
||||
valueHasMutated(): void;
|
||||
|
||||
valueWillMutate(): void;
|
||||
}
|
||||
|
||||
interface KnockoutComputedFunctions extends KnockoutSubscribableFunctions {
|
||||
getDependenciesCount(): number;
|
||||
hasWriteFunction(): bool;
|
||||
}
|
||||
|
||||
interface KnockoutObservableFunctions extends KnockoutSubscribableFunctions {
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayFunctions extends KnockoutObservableFunctions {
|
||||
// General Array functions
|
||||
indexOf(searchElement, fromIndex?: number): number;
|
||||
slice(start: number, end?: number): any[];
|
||||
splice(start: number): any[];
|
||||
splice(start: number, deleteCount: number, ...items: any[]): any[];
|
||||
pop();
|
||||
push(...items: any[]): void;
|
||||
shift();
|
||||
unshift(...items: any[]): number;
|
||||
reverse(): any[];
|
||||
sort(): void;
|
||||
sort(compareFunction): void;
|
||||
|
||||
// Ko specific
|
||||
replace(oldItem: any, newItem: any): void;
|
||||
|
||||
remove(item): any[];
|
||||
removeAll(items: any[]): any[];
|
||||
removeAll(): any[];
|
||||
|
||||
destroy(item): void;
|
||||
destroyAll(items: any[]): void;
|
||||
destroyAll(): void;
|
||||
}
|
||||
|
||||
interface KnockoutSubscribableStatic {
|
||||
fn: KnockoutSubscribableFunctions;
|
||||
|
||||
new (): KnockoutSubscription;
|
||||
}
|
||||
|
||||
interface KnockoutSubscription extends KnockoutSubscribableFunctions {
|
||||
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutComputedStatic {
|
||||
fn: KnockoutComputedFunctions;
|
||||
|
||||
(): KnockoutComputed;
|
||||
(func: Function, context?: any, options?: any): KnockoutComputed;
|
||||
(def: KnockoutComputedDefine): KnockoutComputed;
|
||||
(options?: any): KnockoutComputed;
|
||||
}
|
||||
|
||||
interface KnockoutComputed extends KnockoutComputedFunctions {
|
||||
(): any;
|
||||
(value: any): void;
|
||||
|
||||
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayStatic {
|
||||
|
||||
fn: KnockoutObservableArrayFunctions;
|
||||
|
||||
(): KnockoutObservableArray;
|
||||
(value: any[]): KnockoutObservableArray;
|
||||
}
|
||||
|
||||
interface KnockoutObservableArray extends KnockoutObservableArrayFunctions {
|
||||
(): any[];
|
||||
(value: any[]): void;
|
||||
|
||||
subscribe(callback: (newValue: any[]) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: any[], topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableStatic {
|
||||
fn: KnockoutObservableFunctions;
|
||||
|
||||
(value: string): KnockoutObservableString;
|
||||
(value: Date): KnockoutObservableDate;
|
||||
(value: number): KnockoutObservableNumber;
|
||||
(value: bool): KnockoutObservableBool;
|
||||
(value?: any): KnockoutObservableAny;
|
||||
}
|
||||
|
||||
interface KnockoutObservableBase extends KnockoutObservableFunctions {
|
||||
}
|
||||
|
||||
interface KnockoutObservableAny extends KnockoutObservableBase {
|
||||
|
||||
(): any;
|
||||
(value): void;
|
||||
|
||||
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableString extends KnockoutObservableBase {
|
||||
(): string;
|
||||
(value: string): void;
|
||||
|
||||
subscribe(callback: (newValue: string) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: string, topic?: string);
|
||||
}
|
||||
|
||||
|
||||
interface KnockoutObservableNumber extends KnockoutObservableBase {
|
||||
(): number;
|
||||
(value: number): void;
|
||||
|
||||
subscribe(callback: (newValue: number) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: number, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableBool extends KnockoutObservableBase {
|
||||
(): bool;
|
||||
(value: bool): void;
|
||||
|
||||
subscribe(callback: (newValue: bool) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: bool, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableDate extends KnockoutObservableBase {
|
||||
(): Date;
|
||||
(value: Date): void;
|
||||
|
||||
subscribe(callback: (newValue: Date) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: Date, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutComputedDefine {
|
||||
read(): any;
|
||||
write(any);
|
||||
}
|
||||
|
||||
interface KnockoutBindingContext {
|
||||
$parent: any;
|
||||
$parents: any[];
|
||||
$root: any;
|
||||
$data: any;
|
||||
$index?: number;
|
||||
$parentContext?: KnockoutBindingContext;
|
||||
|
||||
extend(any): any;
|
||||
createChildContext(any): any;
|
||||
}
|
||||
|
||||
interface KnockoutBindingHandler {
|
||||
init?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
|
||||
update?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
|
||||
options?: any;
|
||||
}
|
||||
|
||||
interface KnockoutBindingHandlers {
|
||||
// Controlling text and appearance
|
||||
visible: KnockoutBindingHandler;
|
||||
text: KnockoutBindingHandler;
|
||||
html: KnockoutBindingHandler;
|
||||
css: KnockoutBindingHandler;
|
||||
style: KnockoutBindingHandler;
|
||||
attr: KnockoutBindingHandler;
|
||||
|
||||
// Control Flow
|
||||
foreach: KnockoutBindingHandler;
|
||||
if: KnockoutBindingHandler;
|
||||
ifnot: KnockoutBindingHandler;
|
||||
with: KnockoutBindingHandler;
|
||||
|
||||
// Working with form fields
|
||||
click: KnockoutBindingHandler;
|
||||
event: KnockoutBindingHandler;
|
||||
submit: KnockoutBindingHandler;
|
||||
enable: KnockoutBindingHandler;
|
||||
disable: KnockoutBindingHandler;
|
||||
value: KnockoutBindingHandler;
|
||||
hasfocus: KnockoutBindingHandler;
|
||||
checked: KnockoutBindingHandler;
|
||||
options: KnockoutBindingHandler;
|
||||
selectedOptions: KnockoutBindingHandler;
|
||||
uniqueName: KnockoutBindingHandler;
|
||||
|
||||
// Rendering templates
|
||||
template: KnockoutBindingHandler;
|
||||
}
|
||||
|
||||
interface KnockoutMemoization {
|
||||
memoize(callback);
|
||||
unmemoize(memoId, callbackParams);
|
||||
unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray);
|
||||
parseMemoText(memoText);
|
||||
}
|
||||
|
||||
interface KnockoutVirtualElements {
|
||||
allowedBindings;
|
||||
emptyNode;
|
||||
firstChild;
|
||||
insertAfter;
|
||||
nextSibling;
|
||||
prepend;
|
||||
setDomNodeChildren;
|
||||
}
|
||||
|
||||
interface KnockoutExtenders {
|
||||
throttle(target: any, timeout: number): KnockoutComputed;
|
||||
notify(target: any, notifyWhen: string): any;
|
||||
}
|
||||
|
||||
interface KnockoutUtils {
|
||||
|
||||
fieldsIncludedWithJsonPost: any[];
|
||||
|
||||
arrayForEach(array: any[], action: (any) => void ): void;
|
||||
arrayIndexOf(array: any[], item: any): number;
|
||||
arrayFirst(array: any[], predicate: (item) => bool, predicateOwner?: any): any;
|
||||
arrayRemoveItem(array: any[], itemToRemove: any): void;
|
||||
arrayGetDistinctValues(array: any[]): any[];
|
||||
arrayMap(array: any[], mapping: (item) => any): any[];
|
||||
arrayFilter(array: any[], predicate: (item) => bool): any[];
|
||||
arrayPushAll(array: any[], valuesToPush: any[]): any[];
|
||||
|
||||
extend(target, source);
|
||||
|
||||
emptyDomNode(domNode): void;
|
||||
moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
|
||||
cloneNodes(nodesArray: any[], shouldCleanNodes: bool): any[];
|
||||
setDomNodeChildren(domNode: any, childNodes: any[]): void;
|
||||
replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
|
||||
setOptionNodeSelectionState(optionNode: any, isSelected: bool): void;
|
||||
stringTrim(str: string): string;
|
||||
stringTokenize(str: string, delimiter: string): string;
|
||||
stringStartsWith(str: string, startsWith: string): string;
|
||||
domNodeIsContainedBy(node: any, containedByNode: any): bool;
|
||||
domNodeIsAttachedToDocument(node: any): bool;
|
||||
tagNameLower(element: any): string;
|
||||
registerEventHandler(element: any, eventType: any, handler: Function): void;
|
||||
triggerEvent(element: any, eventType: any): void;
|
||||
unwrapObservable(value: any): any;
|
||||
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: bool): void;
|
||||
setTextContent(element: any, textContent: string): void;
|
||||
setElementName(element: any, name: string): void;
|
||||
ensureSelectElementIsRenderedCorrectly(selectElement);
|
||||
forceRefresh(node: any): void;
|
||||
ensureSelectElementIsRenderedCorrectly(selectElement: any): void;
|
||||
range(min: any, max: any): any;
|
||||
makeArray(arrayLikeObject: any): any[];
|
||||
getFormFields(form: any, fieldName: string): any[];
|
||||
parseJson(jsonString: string): any;
|
||||
stringifyJson(data: any, replacer: Function, space: string): string;
|
||||
postJson(urlOrForm: any, data: any, options: any): void;
|
||||
setHtml(node: Element, html: string): void;
|
||||
setHtml(node: Element, html: () => string): void;
|
||||
|
||||
ieVersion: number;
|
||||
isIe6: bool;
|
||||
isIe7: bool;
|
||||
|
||||
domNodeDisposal;
|
||||
}
|
||||
|
||||
|
||||
interface KnockoutStatic {
|
||||
utils: KnockoutUtils;
|
||||
memoization: KnockoutMemoization;
|
||||
bindingHandlers: KnockoutBindingHandlers;
|
||||
virtualElements: KnockoutVirtualElements;
|
||||
extenders: KnockoutExtenders;
|
||||
|
||||
applyBindings(viewModel: any, rootNode?: any): void;
|
||||
applyBindingsToDescendants(viewModel: any, rootNode: any): void;
|
||||
applyBindingsToNode(node: Element, options: any, viewModel: any): void;
|
||||
|
||||
subscribable: KnockoutSubscribableStatic;
|
||||
observable: KnockoutObservableStatic;
|
||||
computed: KnockoutComputedStatic;
|
||||
observableArray: KnockoutObservableArrayStatic;
|
||||
|
||||
contextFor(node: any): any;
|
||||
isSubscribable(instance: any): bool;
|
||||
toJSON(viewModel: any, replacer?: Function, space?: any): string;
|
||||
toJS(viewModel: any): any;
|
||||
isObservable(instance: any): bool;
|
||||
isComputed(instance: any): bool;
|
||||
dataFor(node: any): any;
|
||||
removeNode(node: Element);
|
||||
cleanNode(node: Element);
|
||||
}
|
||||
|
||||
// Type definitions for Knockout 2.2
|
||||
// Project: http://knockoutjs.com
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
interface KnockoutSubscribableFunctions {
|
||||
extend(source);
|
||||
dispose(): void;
|
||||
peek(): any;
|
||||
valueHasMutated(): void;
|
||||
|
||||
valueWillMutate(): void;
|
||||
}
|
||||
|
||||
interface KnockoutComputedFunctions extends KnockoutSubscribableFunctions {
|
||||
getDependenciesCount(): number;
|
||||
hasWriteFunction(): bool;
|
||||
}
|
||||
|
||||
interface KnockoutObservableFunctions extends KnockoutSubscribableFunctions {
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayFunctions extends KnockoutObservableFunctions {
|
||||
// General Array functions
|
||||
indexOf(searchElement, fromIndex?: number): number;
|
||||
slice(start: number, end?: number): any[];
|
||||
splice(start: number): any[];
|
||||
splice(start: number, deleteCount: number, ...items: any[]): any[];
|
||||
pop();
|
||||
push(...items: any[]): void;
|
||||
shift();
|
||||
unshift(...items: any[]): number;
|
||||
reverse(): any[];
|
||||
sort(): void;
|
||||
sort(compareFunction): void;
|
||||
|
||||
// Ko specific
|
||||
replace(oldItem: any, newItem: any): void;
|
||||
|
||||
remove(item): any[];
|
||||
removeAll(items: any[]): any[];
|
||||
removeAll(): any[];
|
||||
|
||||
destroy(item): void;
|
||||
destroyAll(items: any[]): void;
|
||||
destroyAll(): void;
|
||||
}
|
||||
|
||||
interface KnockoutSubscribableStatic {
|
||||
fn: KnockoutSubscribableFunctions;
|
||||
|
||||
new (): KnockoutSubscription;
|
||||
}
|
||||
|
||||
interface KnockoutSubscription extends KnockoutSubscribableFunctions {
|
||||
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutComputedStatic {
|
||||
fn: KnockoutComputedFunctions;
|
||||
|
||||
(): KnockoutComputed;
|
||||
(func: Function, context?: any, options?: any): KnockoutComputed;
|
||||
(def: KnockoutComputedDefine): KnockoutComputed;
|
||||
(options?: any): KnockoutComputed;
|
||||
}
|
||||
|
||||
interface KnockoutComputed extends KnockoutComputedFunctions {
|
||||
(): any;
|
||||
(value: any): void;
|
||||
|
||||
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayStatic {
|
||||
|
||||
fn: KnockoutObservableArrayFunctions;
|
||||
|
||||
(): KnockoutObservableArray;
|
||||
(value: any[]): KnockoutObservableArray;
|
||||
}
|
||||
|
||||
interface KnockoutObservableArray extends KnockoutObservableArrayFunctions {
|
||||
(): any[];
|
||||
(value: any[]): void;
|
||||
|
||||
subscribe(callback: (newValue: any[]) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: any[], topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableStatic {
|
||||
fn: KnockoutObservableFunctions;
|
||||
|
||||
(value: string): KnockoutObservableString;
|
||||
(value: Date): KnockoutObservableDate;
|
||||
(value: number): KnockoutObservableNumber;
|
||||
(value: bool): KnockoutObservableBool;
|
||||
(value?: any): KnockoutObservableAny;
|
||||
}
|
||||
|
||||
/** use as method to get/set the value */
|
||||
interface KnockoutObservableBase extends KnockoutObservableFunctions {
|
||||
}
|
||||
|
||||
/** use as method to get/set the value
|
||||
can cast to a more appropriate (typed) interface such as KnockoutObservableString or KnockoutObservableNumber
|
||||
*/
|
||||
interface KnockoutObservableAny extends KnockoutObservableBase {
|
||||
|
||||
(): any;
|
||||
(value): void;
|
||||
|
||||
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableString extends KnockoutObservableBase {
|
||||
(): string;
|
||||
(value: string): void;
|
||||
|
||||
subscribe(callback: (newValue: string) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: string, topic?: string);
|
||||
}
|
||||
|
||||
|
||||
interface KnockoutObservableNumber extends KnockoutObservableBase {
|
||||
(): number;
|
||||
(value: number): void;
|
||||
|
||||
subscribe(callback: (newValue: number) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: number, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableBool extends KnockoutObservableBase {
|
||||
(): bool;
|
||||
(value: bool): void;
|
||||
|
||||
subscribe(callback: (newValue: bool) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: bool, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableDate extends KnockoutObservableBase {
|
||||
(): Date;
|
||||
(value: Date): void;
|
||||
|
||||
subscribe(callback: (newValue: Date) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: Date, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutComputedDefine {
|
||||
read(): any;
|
||||
write(any);
|
||||
}
|
||||
|
||||
interface KnockoutBindingContext {
|
||||
$parent: any;
|
||||
$parents: any[];
|
||||
$root: any;
|
||||
$data: any;
|
||||
$index?: number;
|
||||
$parentContext?: KnockoutBindingContext;
|
||||
|
||||
extend(any): any;
|
||||
createChildContext(any): any;
|
||||
}
|
||||
|
||||
interface KnockoutBindingHandler {
|
||||
init?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
|
||||
update?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
|
||||
options?: any;
|
||||
}
|
||||
|
||||
interface KnockoutBindingHandlers {
|
||||
// Controlling text and appearance
|
||||
visible: KnockoutBindingHandler;
|
||||
text: KnockoutBindingHandler;
|
||||
html: KnockoutBindingHandler;
|
||||
css: KnockoutBindingHandler;
|
||||
style: KnockoutBindingHandler;
|
||||
attr: KnockoutBindingHandler;
|
||||
|
||||
// Control Flow
|
||||
foreach: KnockoutBindingHandler;
|
||||
if: KnockoutBindingHandler;
|
||||
ifnot: KnockoutBindingHandler;
|
||||
with: KnockoutBindingHandler;
|
||||
|
||||
// Working with form fields
|
||||
click: KnockoutBindingHandler;
|
||||
event: KnockoutBindingHandler;
|
||||
submit: KnockoutBindingHandler;
|
||||
enable: KnockoutBindingHandler;
|
||||
disable: KnockoutBindingHandler;
|
||||
value: KnockoutBindingHandler;
|
||||
hasfocus: KnockoutBindingHandler;
|
||||
checked: KnockoutBindingHandler;
|
||||
options: KnockoutBindingHandler;
|
||||
selectedOptions: KnockoutBindingHandler;
|
||||
uniqueName: KnockoutBindingHandler;
|
||||
|
||||
// Rendering templates
|
||||
template: KnockoutBindingHandler;
|
||||
}
|
||||
|
||||
interface KnockoutMemoization {
|
||||
memoize(callback);
|
||||
unmemoize(memoId, callbackParams);
|
||||
unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray);
|
||||
parseMemoText(memoText);
|
||||
}
|
||||
|
||||
interface KnockoutVirtualElements {
|
||||
allowedBindings;
|
||||
emptyNode;
|
||||
firstChild;
|
||||
insertAfter;
|
||||
nextSibling;
|
||||
prepend;
|
||||
setDomNodeChildren;
|
||||
}
|
||||
|
||||
interface KnockoutExtenders {
|
||||
throttle(target: any, timeout: number): KnockoutComputed;
|
||||
notify(target: any, notifyWhen: string): any;
|
||||
}
|
||||
|
||||
interface KnockoutUtils {
|
||||
|
||||
fieldsIncludedWithJsonPost: any[];
|
||||
|
||||
arrayForEach(array: any[], action: (any) => void ): void;
|
||||
arrayIndexOf(array: any[], item: any): number;
|
||||
arrayFirst(array: any[], predicate: (item) => bool, predicateOwner?: any): any;
|
||||
arrayRemoveItem(array: any[], itemToRemove: any): void;
|
||||
arrayGetDistinctValues(array: any[]): any[];
|
||||
arrayMap(array: any[], mapping: (item) => any): any[];
|
||||
arrayFilter(array: any[], predicate: (item) => bool): any[];
|
||||
arrayPushAll(array: any[], valuesToPush: any[]): any[];
|
||||
|
||||
extend(target, source);
|
||||
|
||||
emptyDomNode(domNode): void;
|
||||
moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
|
||||
cloneNodes(nodesArray: any[], shouldCleanNodes: bool): any[];
|
||||
setDomNodeChildren(domNode: any, childNodes: any[]): void;
|
||||
replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
|
||||
setOptionNodeSelectionState(optionNode: any, isSelected: bool): void;
|
||||
stringTrim(str: string): string;
|
||||
stringTokenize(str: string, delimiter: string): string;
|
||||
stringStartsWith(str: string, startsWith: string): string;
|
||||
domNodeIsContainedBy(node: any, containedByNode: any): bool;
|
||||
domNodeIsAttachedToDocument(node: any): bool;
|
||||
tagNameLower(element: any): string;
|
||||
registerEventHandler(element: any, eventType: any, handler: Function): void;
|
||||
triggerEvent(element: any, eventType: any): void;
|
||||
unwrapObservable(value: any): any;
|
||||
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: bool): void;
|
||||
setTextContent(element: any, textContent: string): void;
|
||||
setElementName(element: any, name: string): void;
|
||||
ensureSelectElementIsRenderedCorrectly(selectElement);
|
||||
forceRefresh(node: any): void;
|
||||
ensureSelectElementIsRenderedCorrectly(selectElement: any): void;
|
||||
range(min: any, max: any): any;
|
||||
makeArray(arrayLikeObject: any): any[];
|
||||
getFormFields(form: any, fieldName: string): any[];
|
||||
parseJson(jsonString: string): any;
|
||||
stringifyJson(data: any, replacer: Function, space: string): string;
|
||||
postJson(urlOrForm: any, data: any, options: any): void;
|
||||
setHtml(node: Element, html: string): void;
|
||||
setHtml(node: Element, html: () => string): void;
|
||||
|
||||
ieVersion: number;
|
||||
isIe6: bool;
|
||||
isIe7: bool;
|
||||
|
||||
domNodeDisposal;
|
||||
}
|
||||
|
||||
|
||||
interface KnockoutStatic {
|
||||
utils: KnockoutUtils;
|
||||
memoization: KnockoutMemoization;
|
||||
bindingHandlers: KnockoutBindingHandlers;
|
||||
virtualElements: KnockoutVirtualElements;
|
||||
extenders: KnockoutExtenders;
|
||||
|
||||
applyBindings(viewModel: any, rootNode?: any): void;
|
||||
applyBindingsToDescendants(viewModel: any, rootNode: any): void;
|
||||
applyBindingsToNode(node: Element, options: any, viewModel: any): void;
|
||||
|
||||
subscribable: KnockoutSubscribableStatic;
|
||||
observable: KnockoutObservableStatic;
|
||||
computed: KnockoutComputedStatic;
|
||||
observableArray: KnockoutObservableArrayStatic;
|
||||
|
||||
contextFor(node: any): any;
|
||||
isSubscribable(instance: any): bool;
|
||||
toJSON(viewModel: any, replacer?: Function, space?: any): string;
|
||||
toJS(viewModel: any): any;
|
||||
isObservable(instance: any): bool;
|
||||
isComputed(instance: any): bool;
|
||||
dataFor(node: any): any;
|
||||
removeNode(node: Element);
|
||||
cleanNode(node: Element);
|
||||
}
|
||||
|
||||
declare var ko: KnockoutStatic;
|
||||
Reference in New Issue
Block a user