dillon1000/react

Commit

[PropTypes] Add warnings if PropTypes return functions

Summary:
Right now, if a component specifies a propType as, for example,
`myProp: React.PropTypes.shape`, without an actual shape
parameter, any prop type will be accepted, because
`React.PropTypes.shape` returns a function (the actual validator),
not an Error, currently indicating that propType checking passed.

This can create an unfortunate situation where a component looks
like it has fully specified `propTypes`, but in fact does not.

This commit addresses this by warning if a propType checker returns
anything non-falsy that is not an Error (currently all the library
PropTypes return null or an Error).

Test Plan:
Added a unit test; ran `jest` in the root repo directory.
Also ran `grunt lint` and `grunt test`
Browse files
Changed paths3 files
First-parent comparison
M src/classic/element/ReactElementValidator.js ModifiedM src/classic/element/__tests__/ReactElementValidator-test.js ModifiedM src/classic/types/__tests__/ReactPropTypes-test.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…