Merge pull request #26700 from Retsam/equality-comparer

Knockout: remove the any from the typings for equalityComparer
This commit is contained in:
Nathan Shively-Sanders
2018-06-21 10:44:44 -07:00
committed by GitHub
2 changed files with 12 additions and 1 deletions
+5 -1
View File
@@ -17,7 +17,7 @@ interface KnockoutComputedFunctions<T> {
}
interface KnockoutObservableFunctions<T> {
equalityComparer(a: any, b: any): boolean;
equalityComparer(a: T, b: T): boolean;
}
interface KnockoutObservableArrayFunctions<T> {
@@ -78,6 +78,10 @@ interface KnockoutComputedStatic {
interface KnockoutComputed<T> extends KnockoutObservable<T>, KnockoutComputedFunctions<T> {
fn: KnockoutComputedFunctions<any>;
// It's possible for a to be undefined, since the equalityComparer is run on the initial
// computation with undefined as the first argument. This is user-relevant for deferred computeds.
equalityComparer(a: T | undefined, b: T): boolean;
dispose(): void;
isActive(): boolean;
getDependenciesCount(): number;
+7
View File
@@ -601,6 +601,13 @@ function test_misc() {
}
}
ko.observable("foo").equalityComparer = (a, b) => {
return a.toLowerCase() === b.toLowerCase();
};
ko.computed(() => "foo").equalityComparer = (a, b) => {
return (a !== undefined) && a.toLowerCase() === b.toLowerCase();
};
}
interface KnockoutBindingHandlers {