diff --git a/Libraries/Animated/nodes/AnimatedInterpolation.js b/Libraries/Animated/nodes/AnimatedInterpolation.js index d6f5deed041f5a..dac38a30a18662 100644 --- a/Libraries/Animated/nodes/AnimatedInterpolation.js +++ b/Libraries/Animated/nodes/AnimatedInterpolation.js @@ -46,20 +46,23 @@ function createInterpolation( } const outputRange: Array = (config.outputRange: any); - checkInfiniteRange('outputRange', outputRange); const inputRange = config.inputRange; - checkInfiniteRange('inputRange', inputRange); - checkValidInputRange(inputRange); - invariant( - inputRange.length === outputRange.length, - 'inputRange (' + - inputRange.length + - ') and outputRange (' + - outputRange.length + - ') must have the same length', - ); + if (__DEV__) { + checkInfiniteRange('outputRange', outputRange); + checkInfiniteRange('inputRange', inputRange); + checkValidInputRange(inputRange); + + invariant( + inputRange.length === outputRange.length, + 'inputRange (' + + inputRange.length + + ') and outputRange (' + + outputRange.length + + ') must have the same length', + ); + } const easing = config.easing || linear; @@ -276,16 +279,10 @@ function findRange(input: number, inputRange: $ReadOnlyArray) { function checkValidInputRange(arr: $ReadOnlyArray) { invariant(arr.length >= 2, 'inputRange must have at least 2 elements'); + const message = + 'inputRange must be monotonically non-decreasing ' + String(arr); for (let i = 1; i < arr.length; ++i) { - invariant( - arr[i] >= arr[i - 1], - /* $FlowFixMe[incompatible-type] (>=0.13.0) - In the addition expression - * below this comment, one or both of the operands may be something that - * doesn't cleanly convert to a string, like undefined, null, and object, - * etc. If you really mean this implicit string conversion, you can do - * something like String(myThing) */ - 'inputRange must be monotonically non-decreasing ' + arr, - ); + invariant(arr[i] >= arr[i - 1], message); } }