Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(recommend): use Hit type instead of AlgoliaHit #6540

Merged
merged 4 commits into from
Jan 22, 2025

Conversation

raed667
Copy link
Contributor

@raed667 raed667 commented Jan 22, 2025

Summary

Follow-up on #6533

When using sendEvent with Recommend in InstantSearch.js we encounter a typing issue

Type 'AlgoliaHit<Record<string, any>>' is not assignable to type 'Hit'.
  Property '__position' is missing in type 'AlgoliaHit<Record<string, any>>' but required in type '{ __position: number; __queryID?: string | undefined; }'

codesandbox to demonstrate the type issue https://codesandbox.io/p/sandbox/nzkfh7

This is because AlgoliaHit is only meant for hits that don't first go through addAbsolutePosition and addQueryId. This means that the type we actually mean to use is Hit in most cases.

Result

The issue was not caught by yarn type-check initially, I'm not sure how we could have done better to automatically catch it.

@raed667 raed667 requested review from a team, dhayab and sarahdayan and removed request for a team January 22, 2025 07:57
Copy link

codesandbox-ci bot commented Jan 22, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c2a5119:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

@Haroenv Haroenv changed the title fix(recommend): in intantsearch.js use Hit instead of AlgoliaHit fix(recommend): use Hit type instead of AlgoliaHit Jan 22, 2025
@Haroenv Haroenv merged commit 6f2dc2f into master Jan 22, 2025
14 checks passed
@Haroenv Haroenv deleted the fix/recommend/AlgoliaHit-type branch January 22, 2025 09:54
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.

2 participants