Skip to content

Conversation

dardanbujupaj
Copy link
Contributor

@dardanbujupaj dardanbujupaj commented Jul 24, 2025

Pull Request

Related issue

Fixes #1377

What does this PR do?

Use InstantSearchOptions['searchClient'] to define the search client type, similar to how instantsearch.js does it. This fixes the issue where search client won't match the type required by react instantsearch.
I'm not too happy with the import from instantsearch.js/es/lib/InstantSearch.js. InstantSearch (and InstantSearchOptions) should actually be exported by the root types of instantsearch.js, but I assume there's either something wrong with their package definition or the vite/ts config in this repo, but I'm honestly not too proficient with bundling configs.
I also saw (after implementing this) that this is also done similarly in #1378. But I hope we can merge this one more quickly, as it's just a tiny change.

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Summary by CodeRabbit

  • Bug Fixes

    • Corrected the type definition for the search client to ensure improved type accuracy.
  • Chores

    • Added a changeset to document the patch update for the type correction.

Copy link

changeset-bot bot commented Jul 24, 2025

🦋 Changeset detected

Latest commit: 76d659f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@meilisearch/instant-meilisearch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Jul 24, 2025

Walkthrough

A patch changeset was added to document a type correction for the search client in @meilisearch/instant-meilisearch. In the code, the type alias InstantMeiliSearchInstance was updated to align with the searchClient property type from InstantSearchOptions, ensuring compatibility with recent versions of InstantSearch.

Changes

File(s) Change Summary
.changeset/weak-chefs-share.md Added a changeset documenting a patch update for fixing the search client type.
packages/instant-meilisearch/src/types/types.ts Updated InstantMeiliSearchInstance type alias to use InstantSearchOptions['searchClient'] as its base type.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant instantMeiliSearch
    participant InstantSearch (React/Vue/etc.)

    Developer->>instantMeiliSearch: Call instantMeiliSearch(url, apiKey)
    instantMeiliSearch-->>Developer: Return { searchClient }
    Developer->>InstantSearch: Pass searchClient as prop
    InstantSearch->>searchClient: Use for queries (type now matches expectations)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~6 minutes

Poem

In the warren of types, a patch hops in,
To fix a mismatch where bugs had been.
Now clients and searches dance in tune,
No more errors, just harmony soon.
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6872f1 and 76d659f.

📒 Files selected for processing (2)
  • .changeset/weak-chefs-share.md (1 hunks)
  • packages/instant-meilisearch/src/types/types.ts (2 hunks)
🔇 Additional comments (3)
.changeset/weak-chefs-share.md (1)

1-6: LGTM! Changeset follows proper conventions.

The changeset correctly documents the patch update with a clear description that aligns with the PR objectives.

packages/instant-meilisearch/src/types/types.ts (2)

130-133: Type compatibility issue fully resolved

Verified that there are no remaining references to the old SearchClient type that require updating, and all usages of InstantMeiliSearchInstance now correctly leverage InstantSearchOptions['searchClient']. The change cleanly preserves the added clearCache method extension without any downstream breakage.


5-5: 🔍 Verify deep import stability

The deep import path

import type { InstantSearchOptions } from 'instantsearch.js/es/lib/InstantSearch.js'

may break if the internal folder layout changes or if package exports are updated. In this sandbox we couldn’t locate node_modules to confirm, so please:

  • Manually install the target instantsearch.js version and ensure es/lib/InstantSearch.js exists.
  • Pin the package version in your package.json (e.g. ^4.0.0) to avoid unexpected breaking changes.
  • Monitor the official exports in future releases and switch to a supported path once available.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator

@Strift Strift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @dardanbujupaj, and thanks for your contribution 🙌

@Strift Strift added this pull request to the merge queue Jul 24, 2025
Merged via the queue into meilisearch:main with commit 7e0dcc1 Jul 24, 2025
7 checks passed
@dardanbujupaj
Copy link
Contributor Author

@Strift Thanks for the quick merge! Glad I could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InstantMeiliSearchInstance is not assignable to type 'SearchClient | CompositionClient'
2 participants