Skip to content

Commit

Permalink
replace checks for development environment to true to use prod-types …
Browse files Browse the repository at this point in the history
…in production, throw error when checkPropTypes fails
  • Loading branch information
daniel-wer committed Jan 12, 2018
1 parent a94243f commit 527085e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions checkPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

if (process.env.NODE_ENV !== 'production') {
if (true) {
var invariant = require('fbjs/lib/invariant');
var warning = require('fbjs/lib/warning');
var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
Expand All @@ -26,7 +26,7 @@ if (process.env.NODE_ENV !== 'production') {
* @private
*/
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
if (process.env.NODE_ENV !== 'production') {
if (true) {
for (var typeSpecName in typeSpecs) {
if (typeSpecs.hasOwnProperty(typeSpecName)) {
var error;
Expand All @@ -50,6 +50,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
var stack = getStack ? getStack() : '';

warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
throw error;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions factoryWithTypeCheckers.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
PropTypeError.prototype = Error.prototype;

function createChainableTypeChecker(validate) {
if (process.env.NODE_ENV !== 'production') {
if (true) {
var manualPropTypeCallCache = {};
var manualPropTypeWarningCount = 0;
}
Expand All @@ -163,7 +163,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
'Use `PropTypes.checkPropTypes()` to call them. ' +
'Read more at http://fb.me/use-check-prop-types'
);
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
} else if (true && typeof console !== 'undefined') {
// Old behavior for people using React.PropTypes
var cacheKey = componentName + ':' + propName;
if (
Expand Down Expand Up @@ -273,7 +273,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {

function createEnumTypeChecker(expectedValues) {
if (!Array.isArray(expectedValues)) {
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
true ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
return emptyFunction.thatReturnsNull;
}

Expand Down Expand Up @@ -316,7 +316,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {

function createUnionTypeChecker(arrayOfTypeCheckers) {
if (!Array.isArray(arrayOfTypeCheckers)) {
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
true ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
return emptyFunction.thatReturnsNull;
}

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

if (process.env.NODE_ENV !== 'production') {
if (true) {
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
Symbol.for &&
Symbol.for('react.element')) ||
Expand Down

0 comments on commit 527085e

Please sign in to comment.