Skip to content

fix(types): make algoliasearch detection compatible with TS 5.4.5#6244

Merged
Haroenv merged 1 commit intomasterfrom
fix/algoliasearch-typescript-545
Jun 20, 2024
Merged

fix(types): make algoliasearch detection compatible with TS 5.4.5#6244
Haroenv merged 1 commit intomasterfrom
fix/algoliasearch-typescript-545

Conversation

@Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Jun 20, 2024

I can't manage to reproduce this locally, even if i update everything to 5.4.5, but in a fresh Next.js example (like https://codesandbox.io/s/47fy7c) hitsPerPage isn't accepted to Configure (because PlainSearchParameters is any)

This is I believe linked to microsoft/TypeScript#56004, maybe also to sindresorhus/type-fest#846 (although the case seems different).

Essentially before this change the types like ClientLiteV5 were evaluated to any instead of unknown, poisoning the entire type and turning everything into any.

The solution is to first check if typeof AlgoliaSearchLite is any, and if it is any we don't even evaluate the rest of teh type. Of course if it isn't any it works correctly for v5 still.

Again, unfortunately this isn't reproducible in this repo, even when every typescript version is updated to 5.4.5, but at least the error will be fixed

fixes #5989

I can't manage to reproduce this locally, even if i update everything to 5.4.5, but in a fresh Next.js example (like  https://codesandbox.io/s/47fy7c) `hitsPerPage` isn't accepted to Configure (because PlainSearchParameters is any)

This is I believe linked to microsoft/TypeScript#56004, maybe also to sindresorhus/type-fest#846 (although the case seems different).

Essentially before this change the types like `ClientLiteV5` were evaluated to `any` instead of `unknown`, poisoning the entire type and turning everything into any.

The solution is to first check if `typeof AlgoliaSearchLite` is any, and if it is any we don't even evaluate the rest of teh type. Of course if it isn't any it works correctly for v5 still.

Again, unfortunately this isn't reproducible in this repo, even when every typescript version is updated to 5.4.5, but at least the error will be fixed

fixes #5989
@Haroenv Haroenv requested review from a team, dhayab and sarahdayan and removed request for a team June 20, 2024 09:59
@codesandbox-ci
Copy link

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 1d6fd7a:

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 merged commit 4a7afc3 into master Jun 20, 2024
@Haroenv Haroenv deleted the fix/algoliasearch-typescript-545 branch June 20, 2024 10:56
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.

<Configure /> types wrong or conflict with documentation

2 participants