Return Type of hits in Typescript for React Hook

I am getting the hits using the algolia react hook like so:

const { hits } = useHits(props);

Now I want to assign a type to the object that is not of type Hit but extends that type by my custom type Product.

I am trying to do this:

        (hit: Hit<BaseHit> & Product) =>

but it does not work and tells me that the types are incompatible. How can I change the type of hits to an array of products: Product[]?

Not strong enough on TypeScript to understand the type casting going on here, but as long as you are able to return JSX from your customHits() method you should be ok.

Do you maybe need some sort of constructor to build Products from the Hits? Keep in mind a hit is schema-less and may change shape.

Going bigger picture for a second, why do you need to cast your Hits as Products? Are you trying to re-use an existing render function?