Skip to content

HighlightHitParams attribute type should allow number for array indexing #1261

@aldenquimby

Description

@aldenquimby

Description

  • Algolia currently allows highlighting array fields like this:
      {hit._highlightResult.tagNames.map((_, i) => (
        <Fragment key={i}>
          {i !== 0 ? ', ' : null}
          {components.Highlight({
            hit,
            // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- array index is allowed, type is off
            // @ts-expect-error
            attribute: ['tagNames', i],
          })}
        </Fragment>
      ))}
  • example showing this works:
    image

  • ideally the above code would not require the ts-ignore / eslint-ignore

Reproduction

  • I am not sure how to create a preview for this, because it depends on the server-side index having an array field

Preview →

Steps

  • see code above

Expected behavior

  • no type/lint suppression is required

Environment

  • OS: [e.g. Windows / Linux / macOS / iOS / Android]: all
  • Browser: [e.g. Chrome, Safari]: all
  • Autocomplete version: [e.g. 1.0.0]: 1.17.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions