From 527085eda48c0d47bb643489c215c62415bb9e42 Mon Sep 17 00:00:00 2001 From: Daniel Werner Date: Fri, 12 Jan 2018 20:17:45 +0100 Subject: [PATCH] replace checks for development environment to true to use prod-types in production, throw error when checkPropTypes fails --- checkPropTypes.js | 5 +++-- factoryWithTypeCheckers.js | 8 ++++---- index.js | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/checkPropTypes.js b/checkPropTypes.js index 0802c36..0c941d9 100644 --- a/checkPropTypes.js +++ b/checkPropTypes.js @@ -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'); @@ -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; @@ -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; } } } diff --git a/factoryWithTypeCheckers.js b/factoryWithTypeCheckers.js index 7c962b1..21e76ad 100644 --- a/factoryWithTypeCheckers.js +++ b/factoryWithTypeCheckers.js @@ -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; } @@ -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 ( @@ -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; } @@ -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; } diff --git a/index.js b/index.js index 11bfcea..f7c6e49 100644 --- a/index.js +++ b/index.js @@ -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')) ||