Merge pull request #1391 from butlersoftware/computed-polymorphism-fix

Fixed KnockoutComputed polymorphism
This commit is contained in:
Masahiro Wakame
2013-12-06 03:49:14 -08:00
2 changed files with 17 additions and 7 deletions
+4 -7
View File
@@ -68,11 +68,8 @@ interface KnockoutComputedStatic {
(options?: any): KnockoutComputed<any>;
}
interface KnockoutComputed<T> extends KnockoutSubscribable<T>, KnockoutComputedFunctions<T> {
(): T;
(value: T): void;
peek(): T;
interface KnockoutComputed<T> extends KnockoutObservable<T>, KnockoutComputedFunctions<T> {
dispose(): void;
isActive(): boolean;
getDependenciesCount(): number;
@@ -100,8 +97,8 @@ interface KnockoutObservable<T> extends KnockoutSubscribable<T>, KnockoutObserva
(value: T): void;
peek(): T;
valueHasMutated(): void;
valueWillMutate(): void;
valueHasMutated?:{(): void;};
valueWillMutate?:{(): void;};
extend(requestedExtenders: { [key: string]: any; }): KnockoutObservable<T>;
}
+13
View File
@@ -570,4 +570,17 @@ function test_misc() {
ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
$(element).datepicker("destroy");
});
this.observableFactory = function(): KnockoutObservable<number>{
if (true) {
return ko.computed({
read:function(){
return 3;
}
});
} else {
return ko.observable(3);
}
}
}