algolia / algoliasearch-client-javascript

⚡️ A fully-featured and blazing-fast JavaScript API client to interact with Algolia.
https://www.algolia.com/doc/api-client/javascript/getting-started/
MIT License
1.33k stars 221 forks source link

fix(recommend): update TrendingFacetHit facetValue type to string #1498

Closed raed667 closed 8 months ago

raed667 commented 8 months ago

Why

The trending-facets API only returns type string for facetValue.

A follow-up on #1494 as other models return items/hits which are of type RecordWithObjectID

However, trending-facets model returns a list of TrendingFacetHit which (by definition) don't have an objectID property.

How

To simplify the code, we can remove the type argument TObject for trending-facets

Impact

If you're not using TypeScript or the trending-facets model, there is nothing to change. You can ignore the following.

Otherwise, you will need to remove the type argument passed to getTrendingFacets and the code goes from this:

type FacetType = {
  facetName: string;
  facetValue: string;
}
const { results } = await client.getTrendingFacets<FacetType>(/**/)

To this:

const { results } = await client.getTrendingFacets(/**/)
shortcuts commented 8 months ago

BC ok because of low impact

might still worth a minor right?