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
React proptypes mess with checkJs type checking #30007
Comments
Please provide a small code example as text (not just screenshots) |
https://codesandbox.io/s/lxor0y5jn7 |
Tested with typescript@3.4.0-dev.20190220 Self contained example: // @ts-check
import React from "react";
import PropTypes from "prop-types";
class ClassComponent extends React.Component {
render() { return null; }
}
const ComponentWithPropTypes = () => { return null; };
ComponentWithPropTypes.propTypes = { component: PropTypes.func };
const z = (
<ComponentWithPropTypes component={ClassComponent} />
); The error is on
|
Should one even consider classes "regular" functions?
If I have But I guess there is no It could be changed to allow constructors but that would just break types for people who expect to be able to call |
Before ES6 all classes were just regular functions. |
I'd file this over at Definitely Typed, where the type definitions lie. |
Though @AnyhowStep is definitely right - it's unsafe to simply call something that's only been validated as "functiony" since, as he states, a class would throw when called. @kiyutink it might be better to use |
I think |
This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Steps to Reproduce:
Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: