mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Merge pull request #26700 from Retsam/equality-comparer
Knockout: remove the any from the typings for equalityComparer
This commit is contained in:
Vendored
+5
-1
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user