
[React] proptypes-parser: Define React PropTypes with readable string. - joonhocho
https://github.com/joonhocho/proptypes-parser
======
joonhocho
``` const propTypes = parsePropTypes(`{ number: Number string: String!
boolean: Boolean function: Function! date: Date! object: Object! shape: {
nested: Number array: [Number] must: Boolean! }! array: [Number!]!
arrayOfObjects: [{ value: String }!] node: Node element: Element! message:
Message! any: Any! }`); ```

is equivalent to:

``` const propTypes = { number: PropTypes.number, string:
PropTypes.string.isRequired, boolean: PropTypes.bool, function:
PropTypes.func.isRequired, date: PropTypes.instanceOf(Date).isRequired,
object: PropTypes.object.isRequired, shape: PropTypes.shape({ nested:
PropTypes.number, array: PropTypes.arrayOf(PropTypes.number), must:
PropTypes.bool.isRequired, }).isRequired, array: PropTypes.arrayOf(
PropTypes.Number.isRequired, ).isRequired, arrayOfObjects: PropTypes.arrayOf(
PropTypes.shape({ value: PropTypes.string, }).isRequired ), node:
PropTypes.node element: PropTypes.element.isRequired, message:
PropTypes.instanceOf(Message).isRequired, any: PropTypes.any.isRequired, };
```

