Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

InstantMeiliSearchInstance is not assignable to type 'SearchClient | CompositionClient' #1377

Open
Strift opened this issue Feb 7, 2025 · 8 comments · May be fixed by #1378
Open

InstantMeiliSearchInstance is not assignable to type 'SearchClient | CompositionClient' #1377

Strift opened this issue Feb 7, 2025 · 8 comments · May be fixed by #1378
Labels
bug Something isn't working help wanted Extra attention is needed instant-meilisearch

Comments

@Strift
Copy link
Collaborator

Strift commented Feb 7, 2025

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",
@Strift Strift added bug Something isn't working help wanted Extra attention is needed labels Feb 7, 2025
@Strift
Copy link
Collaborator Author

Strift commented Feb 7, 2025

Hi @flevi29, I haven't gotten time to investigate. Could this be related to the updates we performed on the generated types?

@flevi29
Copy link
Collaborator

flevi29 commented Feb 7, 2025

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.

@flevi29
Copy link
Collaborator

flevi29 commented Feb 8, 2025

Apparently function search doesn't exist anymore.

Image

@flevi29 flevi29 linked a pull request Feb 8, 2025 that will close this issue
3 tasks
@flevi29
Copy link
Collaborator

flevi29 commented Feb 8, 2025

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.

@flevi29
Copy link
Collaborator

flevi29 commented Feb 9, 2025

@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.

@Strift
Copy link
Collaborator Author

Strift commented Feb 10, 2025

Thanks for the investigation @flevi29. I'll see how I can prioritize this after the v1.13 release of Meilisearch.

@Strift Strift marked this as a duplicate of #1379 Feb 10, 2025
@DhifMlak
Copy link

DhifMlak commented Feb 20, 2025

@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
                }}

@petr-hajek
Copy link

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working help wanted Extra attention is needed instant-meilisearch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants