diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts
index 71252985d..9b86be44d 100644
--- a/knockout/knockout.d.ts
+++ b/knockout/knockout.d.ts
@@ -1,6 +1,6 @@
-// Type definitions for Knockout 2.3
+// Type definitions for Knockout v3.2.0-beta
// Project: http://knockoutjs.com
-// Definitions by: Boris Yankov
+// Definitions by: Boris Yankov , Igor Oleinikov
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -64,11 +64,12 @@ interface KnockoutComputedStatic {
(): KnockoutComputed;
(func: () => T, context?: any, options?: any): KnockoutComputed;
- (def: KnockoutComputedDefine): KnockoutComputed;
- (options?: any): KnockoutComputed;
+ (def: KnockoutComputedDefine, context?: any): KnockoutComputed;
+ (options?: any, context?: any): KnockoutComputed;
}
interface KnockoutComputed extends KnockoutObservable, KnockoutComputedFunctions {
+ fn: KnockoutComputedFunctions;
dispose(): void;
isActive(): boolean;
@@ -109,6 +110,7 @@ interface KnockoutComputedDefine {
disposeWhen? (): boolean;
owner?: any;
deferEvaluation?: boolean;
+ pure?: boolean;
}
interface KnockoutBindingContext {
@@ -165,7 +167,10 @@ interface KnockoutBindingHandlers {
uniqueName: KnockoutBindingHandler;
// Rendering templates
- template: KnockoutBindingHandler;
+ template: KnockoutBindingHandler;
+
+ // Components (new for v3.2)
+ component: KnockoutBindingHandler;
}
interface KnockoutMemoization {
@@ -190,7 +195,12 @@ interface KnockoutVirtualElements {
interface KnockoutExtenders {
throttle(target: any, timeout: number): KnockoutComputed;
- notify(target: any, notifyWhen: string): any;
+ notify(target: any, notifyWhen: string): any;
+
+ rateLimit(target: any, timeout: number): any;
+ rateLimit(target: any, options: { timeout: number; method?: string; }): any;
+
+ trackArrayChanges(target: any): any;
}
interface KnockoutUtils {
@@ -337,22 +347,28 @@ interface KnockoutArrayChange {
//////////////////////////////////
interface KnockoutTemplateSourcesDomElement {
+ text(): any;
+ text(value: any): void;
- text(valueToWrite?: any): any;
-
- data(key: string, valueToWrite?: any): any;
+ data(key: string): any;
+ data(key: string, value: any): any;
}
+interface KnockoutTemplateAnonymous extends KnockoutTemplateSourcesDomElement {
+ nodes(): any;
+ nodes(value: any): void;
+}
interface KnockoutTemplateSources {
- domElement: KnockoutTemplateSourcesDomElement;
+ domElement: {
+ prototype: KnockoutTemplateSourcesDomElement
+ new (element: Element): KnockoutTemplateSourcesDomElement
+ };
anonymousTemplate: {
-
- prototype: KnockoutTemplateSourcesDomElement;
-
- new (element: Element): KnockoutTemplateSourcesDomElement;
+ prototype: KnockoutTemplateAnonymous;
+ new (element: Element): KnockoutTemplateAnonymous;
};
}
@@ -387,17 +403,28 @@ interface KnockoutTemplateEngine extends KnockoutNativeTemplateEngine {
interface KnockoutStatic {
utils: KnockoutUtils;
memoization: KnockoutMemoization;
- bindingHandlers: KnockoutBindingHandlers;
+
+ bindingHandlers: KnockoutBindingHandlers;
+ getBindingHandler(handler: string): KnockoutBindingHandler;
+
virtualElements: KnockoutVirtualElements;
extenders: KnockoutExtenders;
applyBindings(viewModel: any, rootNode?: any): void;
- applyBindingsToDescendants(viewModel: any, rootNode: any): void;
+ applyBindingsToDescendants(viewModel: any, rootNode: any): void;
+ applyBindingAccessorsToNode(node: Node, bindings: (bindingContext: KnockoutBindingContext, node: Node) => {}, bindingContext: KnockoutBindingContext): void;
+ applyBindingAccessorsToNode(node: Node, bindings: {}, bindingContext: KnockoutBindingContext): void;
+ applyBindingAccessorsToNode(node: Node, bindings: (bindingContext: KnockoutBindingContext, node: Node) => {}, viewModel: any): void;
+ applyBindingAccessorsToNode(node: Node, bindings: {}, viewModel: any): void;
applyBindingsToNode(node: Element, options: any, viewModel: any): void;
subscribable: KnockoutSubscribableStatic;
observable: KnockoutObservableStatic;
- computed: KnockoutComputedStatic;
+
+ computed: KnockoutComputedStatic;
+ pureComputed(evaluatorFunction: () => T, context?: any): KnockoutComputed;
+ pureComputed(options: KnockoutComputedDefine, context?: any): KnockoutComputed;
+
observableArray: KnockoutObservableArrayStatic;
contextFor(node: any): any;
@@ -412,7 +439,9 @@ interface KnockoutStatic {
cleanNode(node: Element): Element;
renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any;
renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any;
- unwrap(value: any): any;
+ unwrap(value: any): any;
+
+ computedContext: KnockoutComputedContext;
//////////////////////////////////
// templateSources.js
@@ -499,7 +528,10 @@ interface KnockoutStatic {
/////////////////////////////////
- bindingProvider: any;
+ bindingProvider: {
+ instance: KnockoutBindingProvider;
+ new (): KnockoutBindingProvider;
+ }
/////////////////////////////////
// selectExtensions.js
@@ -513,6 +545,47 @@ interface KnockoutStatic {
};
}
+interface KnockoutBindingProvider {
+ nodeHasBindings(node: Node): boolean;
+ getBindings(node: Node, bindingContext: KnockoutBindingContext): {};
+ getBindingAccessors?(node: Node, bindingContext: KnockoutBindingContext): { [key: string]: string; };
+}
+
+interface KnockoutComponents {
+ register(componentName: string, definition: KnockoutComponentDefinition): void;
+ isRegistered(componentName: string): boolean;
+ unregister(componentName: string): void;
+ get(componentName: string, callback: (definition: KnockoutComponentDefinition) => void): void;
+ clearCachedDefinition(componentName: string): void
+ defaultLoader: KnockoutComponentLoader;
+ loaders: KnockoutComponentLoader[];
+ getComponentNameForNode(node: Node): string;
+}
+
+interface KnockoutComponentDefinition {
+ template: Node[];
+ createViewModel?(params: any, options: { element: Node; }): any;
+}
+
+interface KnockoutComponentLoader {
+ getConfig? (componentName: string, callback: (result: KnockoutComponentConfig) => void): void;
+ loadComponent? (componentName: string, config: KnockoutComponentConfig, callback: (result: KnockoutComponentDefinition) => void): void;
+ loadTemplate? (componentName: string, templateConfig: any, callback: (result: Node[]) => void): void;
+ loadViewModel? (componentName: string, viewModelConfig: any, callback: (result: any) => void): void;
+ suppressLoaderExceptions?: boolean;
+}
+
+interface KnockoutComponentConfig {
+ template: any;
+ createViewModel?: any;
+}
+
+interface KnockoutComputedContext {
+ getDependenciesCount(): number;
+ isInitial: boolean;
+ isSleeping: boolean;
+}
+
declare module "knockout" {
export = ko;
}
diff --git a/knockout/tests/knockout-templatingBehaviors-tests.ts b/knockout/tests/knockout-templatingBehaviors-tests.ts
index 7be02d4cd..50ec27572 100644
--- a/knockout/tests/knockout-templatingBehaviors-tests.ts
+++ b/knockout/tests/knockout-templatingBehaviors-tests.ts
@@ -363,11 +363,11 @@ describe('Templating', function() {
// and external (non-rewritten) ones
var originalBindingProvider = ko.bindingProvider.instance;
ko.bindingProvider.instance = {
- nodeHasBindings: function(node, bindingContext) {
- return (node.tagName == 'EM') || originalBindingProvider.nodeHasBindings(node, bindingContext);
+ nodeHasBindings: function(node) {
+ return ((node).tagName == 'EM') || originalBindingProvider.nodeHasBindings(node);
},
getBindings: function(node, bindingContext) {
- if (node.tagName == 'EM')
+ if ((node).tagName == 'EM')
return { text: ++model.numBindings };
return originalBindingProvider.getBindings(node, bindingContext);
}