Skip to content

[bug]: wrong typing for SearchResult #1584

Closed
@dmendiboure

Description

@dmendiboure

Description

Here is the code to reproduce the bug:

const client = algoliasearch("*******", "********");

const response = await client.search<{ title: string }>({
  requests: [
    {
      indexName: "first_index",
      query,
      hitsPerPage: 5,
    },
    {
      indexName: "second_index",
      query,
      hitsPerPage: 5,
    },
    {
      indexName: "third_index",
      query,
      hitsPerPage: 5,
    },
  ],
});

Image

It seems that the SearchResult type only takes SearchForFacetValuesResponse into account.

In the source code, the following typing is used:

type SearchResult<T = Record<string, unknown>> = SearchResponse<T> | SearchForFacetValuesResponse;

Do you think the following patch might work?

type SearchResult<T = Record<string, unknown>> = SearchResponse<T> & SearchForFacetValuesResponse;

Client

Search

Version

5.23.4

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions