After a discussion with @spicyj we decided to keep the warning even though the functions will throw in production. The warning is the only way to learn about that.
We should also document how to pass the secret through in case you know what you're doing.
even though the functions will throw in production
particularly _because_ the functions will throw in production
Out of curiosity, why will they throw errors in 16.0?
Because we will eliminate all that code in production. It doesn't seem to make sense to ship real code for PropTypes validators if it's normally never used in prod. Therefore we'll replace them all with an empty function. To make this behavior clear we'll make it throw so people don't rely on them for validating e.g. user input.
You could also create PropTypes on demand, for example
Object.defineProperties(api, {'PropTypes': {
// only construct PropTypes when used
get: function () {
return (
Object.defineProperty(
this,
'PropTypes',
{ value: generatePropTypes() }
),
this.PropTypes
);
},
configurable: true,
enumerable: true
....
That would defeat the point by including even more code, rather than making the production bundle smaller.
Most helpful comment
Because we will eliminate all that code in production. It doesn't seem to make sense to ship real code for PropTypes validators if it's normally never used in prod. Therefore we'll replace them all with an empty function. To make this behavior clear we'll make it throw so people don't rely on them for validating e.g. user input.