mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-11 11:50:54 +08:00
Knockout: amended components.register to overloads supported by 3.2
KO Version 3.2 added components. The .register method in the current code is incorrect and does not support the correct overloads permitted.
This commit is contained in:
Vendored
+51
-1
@@ -556,7 +556,13 @@ interface KnockoutBindingProvider {
|
||||
}
|
||||
|
||||
interface KnockoutComponents {
|
||||
register(componentName: string, definition: KnockoutComponentDefinition): void;
|
||||
// overloads for register method:
|
||||
register(componentName: string, config: KnockoutComponentRegister): void;
|
||||
register(componentName: string, config: KnockoutComponentRegisterStringTemplate): void;
|
||||
register(componentName: string, config: KnockoutComponentRegisterFnViewModel): void;
|
||||
register(componentName: string, config: KnockoutComponentRegisterStringTemplateFnViewModel): void;
|
||||
register(componentName: string, config: KnockoutComponentRegisterAMD): void;
|
||||
|
||||
isRegistered(componentName: string): boolean;
|
||||
unregister(componentName: string): void;
|
||||
get(componentName: string, callback: (definition: KnockoutComponentDefinition) => void): void;
|
||||
@@ -566,6 +572,50 @@ interface KnockoutComponents {
|
||||
getComponentNameForNode(node: Node): string;
|
||||
}
|
||||
|
||||
/* interfaces for register overloads*/
|
||||
|
||||
interface KnockoutComponentRegister {
|
||||
template: KnockoutComponentTemplate;
|
||||
viewModel?: KnockoutComponentConfigViewModel;
|
||||
}
|
||||
|
||||
interface KnockoutComponentRegisterAMD {
|
||||
// load self-describing module using AMD module name
|
||||
require: string;
|
||||
}
|
||||
|
||||
interface KnockoutComponentRegisterFnViewModel {
|
||||
template: KnockoutComponentTemplate;
|
||||
viewModel?: (params: any) => any;
|
||||
}
|
||||
|
||||
interface KnockoutComponentRegisterStringTemplate {
|
||||
template: string;
|
||||
viewModel?: KnockoutComponentConfigViewModel;
|
||||
}
|
||||
|
||||
interface KnockoutComponentRegisterStringTemplateFnViewModel {
|
||||
template: string;
|
||||
viewModel?: (params: any) => any;
|
||||
}
|
||||
|
||||
interface KnockoutComponentConfigViewModel {
|
||||
instance?: any;
|
||||
createViewModel? (params?: any, componentInfo?: KnockoutComponentInfo): any;
|
||||
require?: string;
|
||||
}
|
||||
|
||||
interface KnockoutComponentTemplate {
|
||||
// specify element id (string) or a node
|
||||
element?: any;
|
||||
// AMD module load
|
||||
require?: string;
|
||||
}
|
||||
|
||||
interface KnockoutComponentInfo {
|
||||
element: any;
|
||||
}
|
||||
/* end register overloads */
|
||||
interface KnockoutComponentDefinition {
|
||||
template: Node[];
|
||||
createViewModel?(params: any, options: { element: Node; }): any;
|
||||
|
||||
Reference in New Issue
Block a user