algolia / algoliasearch-client-javascript

⚡️ A fully-featured and blazing-fast JavaScript API client to interact with Algolia.
https://www.algolia.com/doc/api-client/javascript/getting-started/
MIT License
1.33k stars 222 forks source link

TypeScript error with v5 and `@algolia/autocomplete-core` #1539

Closed bradlc closed 3 months ago

bradlc commented 3 months ago

Since upgrading to algoliasearch@5.0.0 we're seeing a TypeScript error when using createAutocomplete from the @algolia/autocomplete-core package. Otherwise, everything seems to work correctly as before.

Type '{ indexName: string; query: string; params: { hitsPerPage: number; }; }' is not assignable to type 'LegacySearchQuery'.
  Object literal may only specify known properties, and 'query' does not exist in type 'LegacySearchQuery'.typescript(2322)

Reproduction →

[!NOTE] The code is taken from the example here. In CodeSandbox there's an additional error on getSources that we aren't seeing in our app.

Haroenv commented 3 months ago

Ah that's right, that example is indeed not compatible with v5, the query should be inside params. As that works for v4 too I'll update the docs

shortcuts commented 3 months ago

Thanks @Haroenv

bradlc commented 3 months ago

Ah gotcha, thank you so much for the quick response!

Haroenv commented 3 months ago

No problem, I just realised I forgot some files in that doc PR, so a follow-up is made to ensure this pattern is used everywhere.