-
Notifications
You must be signed in to change notification settings - Fork 331
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(core): allow number index for hit attribute #1261 #1262
Conversation
@@ -11,7 +11,7 @@ type HighlightHitParams<THit> = { | |||
* | |||
* You can use the array syntax to reference nested attributes. | |||
*/ | |||
attribute: keyof THit | string[]; | |||
attribute: keyof THit | (string | number)[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative would be to add @algolia/autocomplete-shared
as a dependency in this example project, and import the existing type, so this doesn't need to be duplicated
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 0080a87:
|
@@ -1,4 +1,4 @@ | |||
export type ParseAlgoliaHitParams<TItem> = { | |||
hit: TItem; | |||
attribute: keyof TItem | string[]; | |||
attribute: keyof TItem | (string | number)[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative, if preferred, could be to change this type to:
export type ParseAlgoliaHitParams<TItem> = Pick<HighlightHitParams<TItem>, 'hit' | 'attribute'>;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's go with this solution! ideally we'd do a proper traversal of the Hit to create the highlight types, but in the past that caused issues with types that got too long. This is a good stopgap solution
Thank you @Haroenv |
Summary
Result