Closed Poyoman39 closed 5 years ago
Note this already exists as and
in https://npmjs.com/airbnb-prop-types (also note that shape
always requires an object)
True enough ! :D Thank you for your answer ... i guess i should have googled it a bit more ...
This is a feature request:
With proptypes, we already have "oneOfType" type checker, what about a "bothOfType" type checker ?
What is the use case: You have these proptypes:
const vehicle = propTypes.shape({ engine: propTypes.string })
const car = propTypes.shape({ engine: propTypes.string, wheels: propTypes.number })
It would be fine to be able to write it like that:
const car = propTypes.bothOfType([vehicle, propTypes.shape({ wheels: propTypes.number })])
In case vehicle and car have a lot of properties it allows doing type refactoring.
What do you think about it ?