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

Function types are typed as any #13

Closed
mattcompiles opened this issue Jul 15, 2020 · 3 comments
Closed

Function types are typed as any #13

mattcompiles opened this issue Jul 15, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@mattcompiles
Copy link

Description

Function types (e.g. event handlers) are typed as any. I'm not convinced react-polymorphic-box is at fault here but thought I'd raise it to discuss. In my example typescript seems to infer the correct type for the event handler (pictured below), however when implementing the handler it is not typed.

image

Reproduction

import React from 'react';
import { Box } from 'react-polymorphic-box'; 

const Test = () => (
  <Box
    as="li"
    onMouseDown={(event) => {
      // event is implicitly typed as any
    }}
  />
);

Expected behaviour

The event handler should be typed as expected.

Actual behaviour

Event handlers seem to be typed as any.

image

Environment

System:

  • OS: macOS Mojave 10.14.6
  • CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
  • Memory: 42.69 MB / 16.00 GB
  • Shell: 5.3 - /bin/zsh

Binaries:

  • Node: 12.18.2
  • Yarn: 1.22.4
  • npm: 6.14.5

Browsers:

  • Chrome: 84.0.4147.89
  • Firefox: 78.0.1
  • Safari: 12.1.2

npmPackages:

  • react-polymorphic-box: ^2.0.4 => 2.0.4
  • typescript: 3.9.6
@mattcompiles mattcompiles added the bug Something isn't working label Jul 15, 2020
@kripod
Copy link
Owner

kripod commented Jul 15, 2020

Thank you for submitting this issue! As far as I know, this might be fixed on the language level by a forthcoming release of TypeScript. Please follow microsoft/TypeScript#31023 for more information!

@mattcompiles
Copy link
Author

Cheers bud, you're all over it. 👍

@corbanbrook
Copy link

corbanbrook commented Nov 11, 2022

This is what i did to get event handlers to type correctly.

playground link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants