The async parameter of Bloodhound.search is now optional (#23365)

The search function assigns a noop call inside the function body if the async parameter is omitted (bloodhound.js line 137), so it's safe to make this optional in the type signature.
This commit is contained in:
Mark Bell
2018-02-02 21:56:49 +00:00
committed by Sheetal Nandi
parent 2ab14041f4
commit d5b9413803
2 changed files with 5 additions and 4 deletions

View File

@@ -1186,7 +1186,7 @@ declare class Bloodhound<T> {
* @param async Async callback.
* @returns The data that matches query.
*/
public search(query: string, sync: (datums: T[]) => void, async: (datums: T[]) => void): T[];
public search(query: string, sync: (datums: T[]) => void, async?: (datums: T[]) => void): T[];
/**
* Returns all items from the internal search index.

View File

@@ -213,10 +213,11 @@ function test_bloodhout() {
// search
var sync: (datums: string[]) => {};
var async: (datums: string[]) => {};
var data2: string[] = engine.search("query", sync, async);
var data2: string[] = engine.search("query", sync);
var data3: string[] = engine.search("query", sync, async);
// all
var data3: string[] = engine.all();
var data4: string[] = engine.all();
// clear
var engine1: Bloodhound<string> = engine.clear();
@@ -463,4 +464,4 @@ function test_bloodhout() {
}
};
}
}
}