SearchOptions.facetFilters type is too restrictive
eliasnorrby opened this issue · comments
Elias Norrby commented
As per the docs, SearchOptions.facetFilters
can be a list with elements being a list of string | string[]
:
index.search('', {
facetFilters: [["author:Stephen King", "genre:Horror"], "publisher:Penguin"]
});
The currently exported type, however, requires all elements to be of the same type, i.e. either string
or string[]
:
readonly facetFilters?: string | readonly string[] | ReadonlyArray<readonly string[]>;
Attempting to call client.search
with an array of mixed contents results in this error:
error TS2322: Type '(string | string[])[]' is not assignable to type 'string | readonly string[] | readonly (readonly string[])[]'.
Type '(string | string[])[]' is not assignable to type 'readonly (readonly string[])[]'.
Type 'string | string[]' is not assignable to type 'readonly string[]'.
Type 'string' is not assignable to type 'readonly string[]'.
{ facetFilters: ['abc:123', ['def:456','one:two']] },