Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error for KeyboardEventHandler #377

Open
igoratf opened this issue Aug 24, 2021 · 1 comment
Open

Type error for KeyboardEventHandler #377

igoratf opened this issue Aug 24, 2021 · 1 comment

Comments

@igoratf
Copy link

igoratf commented Aug 24, 2021

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
I am trying to use the lib with TypeScript and getting an error related to KeyboardEventHandler:

Types of property 'onKeyDown' are incompatible.
      Type 'KeyboardEventHandler<Element>' is not assignable to type 'KeyboardEventHandler<HTMLInputElement>'.
        Types of parameters 'event' and 'event' are incompatible.
          Property 'code' is missing in type 'KeyboardEvent<HTMLInputElement>' but required in type 'KeyboardEvent<Element>'

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Just following the docs is throwing this compilation error for the input element.

What is the expected behavior?
Changing onKeyDown: React.KeyboardEventHandler to onKeyDown: React.KeyboardEventHandler<HTMLInputElement> seems to work properly and compile.

Which versions of ReactPlacesAutocomplete, and which browser / OS are affected by this issue?
"react-places-autocomplete": "^7.3.0",
"@types/react-places-autocomplete": "^7.2.8",

@mikestecker
Copy link

mikestecker commented Sep 8, 2021

Having the same issue. The bug seems to happen with @types/react and @types/react-dom present in the package.json. Removing these dependencies solves the problem. Another way of solving is to upgrade React and these @types packages to React 17

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

No branches or pull requests

2 participants