Skip to content

SearchOptions.facetFilters type is too restrictive #1383

@eliasnorrby

Description

@eliasnorrby

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']] },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions