Skip to content

TypeError with TS@5.1.3: Property 'hitsPerPage' does not exist on type 'IntrinsicAttributes & PlainSearchParameters' #5658

Closed
algolia/algoliasearch-helper-js
#943
@jcwillox

Description

🐛 Current behavior

So this might be a bug with typescript, but it's the only library that broke when updating it so I'm going to create the bug report here.

When running with version 5.1.3 of typescript and react-instantsearch-hooks-web I get a type error on the Configure component, it appears it's no longer inferring the SearchOptions correctly. Downgrading to version 5.0.4 of typescript fixes the issue.

> tsc --noEmit

components/SearchApp/SearchApp.tsx:28:18 - error TS2322: Type '{ hitsPerPage: number; filters: string | undefined; }' is not assignable to type 'IntrinsicAttributes & PlainSearchParameters'.
  Property 'hitsPerPage' does not exist on type 'IntrinsicAttributes & PlainSearchParameters'.

28       <Configure hitsPerPage={hitsPerPage} filters={filters} />
                    ~~~~~~~~~~~

🔍 Steps to reproduce

  1. Install the following packages react-instantsearch-hooks-web@6.44.1 typescript@5.1.3
  2. Create a component with
<InstantSearch searchClient={searchClient} indexName={indexName}>
  <Configure hitsPerPage={hitsPerPage} filters={filters} />
  {children}
</InstantSearch>
  1. Run tsc --noEmit
> tsc

components/SearchApp/SearchApp.tsx:28:18 - error TS2322: Type '{ hitsPerPage: number; filters: string | undefined; }' is not assignable to type 'IntrinsicAttributes & PlainSearchParameters'.
  Property 'hitsPerPage' does not exist on type 'IntrinsicAttributes & PlainSearchParameters'.

28       <Configure hitsPerPage={hitsPerPage} filters={filters} />
                    ~~~~~~~~~~~

Or checkout this repro https://stackblitz.com/edit/algolia-ts-bug-2mfs3u?file=app%2FSearchApp.tsx and run npm run typecheck in the terminal.

Live reproduction

https://stackblitz.com/edit/algolia-ts-bug-2mfs3u?file=app%2FSearchApp.tsx

💭 Expected behavior

There should be no typescript error as with previous versions of typescript.

Package version

react-instantsearch-hooks-web@6.44.1, typescript@5.1.3

Operating system

Windows, Linux

Browser

Chrome

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions