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

Support flow annotations for component props #382

Merged
merged 1 commit into from
Jan 7, 2016

Conversation

phpnode
Copy link
Contributor

@phpnode phpnode commented Jan 5, 2016

This PR adds support for using flow type annotations for class props instead of propTypes. Flow added support for this quite recently in: facebook/flow#850

The syntax looks like this:

type Person = {
  name: {
    firstName: string;
    lastName: string;
  },
  age: number;
};
type Props = {
  greeting: string;
  people: Person[];
};
class Hello extends React.Component {
  props: Props;

  render () {
    const names = [];
    for (let i = 0; i < this.props.people.length; i++) {
      names.push(this.props.people[i].name.firstName);
    }
    return <div>{this.props.greeting}, {names.join(', ')}</div>;
  }
}

@yannickcr
Copy link
Member

Wow! This is really great!

Can you squash your commits ? Then I think we'll be good to go :)

@phpnode
Copy link
Contributor Author

phpnode commented Jan 7, 2016

@yannickcr squashed

yannickcr added a commit that referenced this pull request Jan 7, 2016
Add support for flow annotations in prop-types
@yannickcr yannickcr merged commit a929545 into jsx-eslint:master Jan 7, 2016
@yannickcr
Copy link
Member

Merged, thanks!

@phpnode
Copy link
Contributor Author

phpnode commented Jan 7, 2016

awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants