I've seen some projects that define prop-types in separate files in order to reuse their definitions. The problem is that we can't extend prop-types definitions. Let's say we have a set of prop-types called Person.type.js:
Also, exporting a plain object from 'Person.type.js' is not an option since we may want the ability to use those properties directly, and for the matter of consistency, we may not want to use it like PropTypes.shape(PersonType) (that would be a possible workaround) whenever we use the PersonType directly as a prop.
So would be great to have a method like PropTypes.extend(shape, additionalFields) so we could be able to write something like:
I've seen some projects that define prop-types in separate files in order to reuse their definitions. The problem is that we can't extend prop-types definitions. Let's say we have a set of prop-types called
Person.type.js
:The problem is that we can't do something like:
Also, exporting a plain object from 'Person.type.js' is not an option since we may want the ability to use those properties directly, and for the matter of consistency, we may not want to use it like
PropTypes.shape(PersonType)
(that would be a possible workaround) whenever we use the PersonType directly as a prop.So would be great to have a method like
PropTypes.extend(shape, additionalFields)
so we could be able to write something like: