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

Fix required prop types for classes with annotated methods. #1112

Merged

Commits on May 26, 2017

  1. Fix required prop types for classes with annotated methods.

    The `react/prop-types` rule incorrectly considers  flow type
    annotations on class methods with arguments named `props` as
    prop type declarations for the class, even though flow itself
    gives them no such weight.
    
    When a react component is defined as a class extending `React.Component`,
    and it defines a method that takes an annotated argument named `props`,
    then, even though flow still thinks the props have `any` type, the
    `prop-types` rule will not produce 'missing in props validation' errors.
    
    A pattern that gets used a lot in React components is as follows:
    ```javascript
    type Props = {...};
    class Comp extends React.Component {
      constructor(props: Props) {
        super(props);
        // do something...
      }
    
      // ...
    }
    ```
    which makes this especially nefarious.
    Ethan Goldberg committed May 26, 2017
    Configuration menu
    Copy the full SHA
    6e8f543 View commit details
    Browse the repository at this point in the history