From d5b941380368ea3ed9fcf81a09bc48dcb8d387fc Mon Sep 17 00:00:00 2001 From: Mark Bell Date: Fri, 2 Feb 2018 21:56:49 +0000 Subject: [PATCH] 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. --- types/typeahead/index.d.ts | 2 +- types/typeahead/typeahead-tests.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/types/typeahead/index.d.ts b/types/typeahead/index.d.ts index 715db1d126..a000bc8f99 100644 --- a/types/typeahead/index.d.ts +++ b/types/typeahead/index.d.ts @@ -1186,7 +1186,7 @@ declare class Bloodhound { * @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. diff --git a/types/typeahead/typeahead-tests.ts b/types/typeahead/typeahead-tests.ts index fb40040dac..0123d3c70c 100644 --- a/types/typeahead/typeahead-tests.ts +++ b/types/typeahead/typeahead-tests.ts @@ -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 = engine.clear(); @@ -463,4 +464,4 @@ function test_bloodhout() { } }; } -} \ No newline at end of file +}