InstantMeiliSearchInstance is not assignable to type 'SearchClient | CompositionClient'
Summary
The instantsearch client (@meilisearch/instant-meilisearch) typing is incompatible with the latest release of instantsearch.
Context
Description
The types expected by the latest versions of react-instantsearch and the client returned by @meilisearch/instant-meilisearch and meilisearch do not match.
Versions used:
const { searchClient } = instantMeiliSearch('url', 'apiKey')
return (
<InstantSearch indexName="index" searchClient={searchClient}>
)
Current behavior
Since the new update of the library, a type error occurs when passing the search client returned by instant-meilisearch to the InstantSearch component.
Error:
Type 'InstantMeiliSearchInstance' is not assignable to type 'SearchClient | CompositionClient'.
(The searchClient prop expects a SearchClient | CompositionClient type)
Expected behavior
No error should occur.
Environment (please complete the following information):
- "meilisearch": "^0.48.2",
- "@meilisearch/instant-meilisearch": "^0.24.0",
- "react-instantsearch": "^7.15.3",
Hi @flevi29, I haven't gotten time to investigate. Could this be related to the updates we performed on the generated types?
I'm going to investigate it, but I doubt it's us, we're probably just out of date. Unless previous versions worked fine, but even then it's possible. One thing's for sure, the error message is not being very helpful.
Apparently function search doesn't exist anymore.
I'm actually not sure what's the problem here, Algolia types are such a cluster****, I've opened #1378, for now I'm leaving it.
@Strift Okay, I've taken a look at the source code. There really isn't a search and searchForFacetValues anymore. There's only scheduleSearch now, and it doesn't take any arguments. This requires major changes in the code, but I don't really want to work on this that much. Maybe for now we can require an older instantsearch.js, and when you or anyone else from the team has time to investigate and adapt to the newer version of Instantsearch we'll switch to it.
Thanks for the investigation @flevi29. I'll see how I can prioritize this after the v1.13 release of Meilisearch.
@flevi29 this is how i am currently using it (search() and other func are inside .client)
searchClient={{
search: searchClient?.client?.search,
searchForFacetValues: searchClient?.client?.searchForFacetValues,
initIndex: searchClient?.client?.initIndex,
addAlgoliaAgent: searchClient?.client?.addAlgoliaAgent,
getRecommendations: searchClient?.client?.getRecommendations,
...searchClient
}}
This is not only issue of the latest instantsearch. I ran into this issue with react-instantsearch 7.13.9 as well after updating to 0.24.0
What is the last compatible instant search version? I'm also running into this issue.
So we should forget about instant search for while ? As @kaylanhua said, maybe there would be a workaround by downgrading the depencies to the last compatible version ?
So we should forget about instant search for while ? As @kaylanhua said, maybe there would be a workaround by downgrading the depencies to the last compatible version ?
I just have a ts error, but everything works, the latest version.
Hi folks, just to clarify, someone coming from the outside...
- Do we have this typing issue since which
meilisearch-jsversion? - Is this issue due to a
meilisearch-jsupgrade or aninstantsearchone?
CC: @Strift if this is preventing people from using the library (type issues can be very bad for the DX) we should give this a higher priority :)
I have this typing issue with the latest release of "@meilisearch/instant-meilisearch". downgrade "@meilisearch/instant-meilisearch" to "0.23.0" is ok. the working config:
- "@meilisearch/instant-meilisearch": "0.23.0",
- "next": "latest",
- "react": "latest",
- "react-dom": "latest",
- "react-instantsearch": "latest",
- "react-instantsearch-nextjs": "^0.4.9",