algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 389 forks source link

facetFilters is typed incorrectly #3486

Closed kanehara closed 1 year ago

kanehara commented 2 years ago

🐛 Bug description

facetFilters is typed as readonly facetFilters?: string | readonly string[] | ReadonlyArray<readonly string[]>. This does not allow for a combination of AND / OR queries like so: facetFilters: ['filter1', ['filter1', 'filter2']]

🔍 Bug reproduction

  1. Pass ['filter1', ['filter2', 'filter3']] into facetFilters arg
  2. Get TS error

💭 Expected behavior

facetFilters should be typed as string | (string | string[])[]

🖥 Screenshots

Screen Shot 2022-05-27 at 5 50 01 AM

Environment

Additional context

Haroenv commented 2 years ago

Which facetFilters type is it you use?

kanehara commented 2 years ago

What do you mean? I'd like to apply an AND filter in conjunction with an OR filter. This works against the Algolia API but it isn't typed as being supported.

Haroenv commented 2 years ago

Sorry, I meant which code are you running? FacetFilters is defined in many places and I'm not sure which one is incorrect.

Also note that if you're using other widgets like RefinementList, they already use the facetFilters key and will override a parameter set by configure (or maybe get confused by it). If you want to set a standalone filter that doesn't get touched by any other InstantSearch code, filters is the best choice.

I'm still interested in knowing which code has that type, thanks!

FabienMotte commented 1 year ago

Hey!

We're doing a round of cleanup before migrating this repository to the new InstantSearch monorepo. This issue seems not to have generated much activity lately, so we're going to close it. Feel free to reopen it if you still have the type error.

We recommend anyone who is currently using React InstantSearch v6 to migrate to Hooks.