@@ -46,20 +46,23 @@ function createInterpolation(
46
46
}
47
47
48
48
const outputRange : Array < number > = (config.outputRange: any);
49
- checkInfiniteRange('outputRange', outputRange);
50
49
51
50
const inputRange = config.inputRange;
52
- checkInfiniteRange('inputRange', inputRange);
53
- checkValidInputRange(inputRange);
54
51
55
- invariant(
56
- inputRange.length === outputRange.length,
57
- 'inputRange (' +
58
- inputRange.length +
59
- ') and outputRange (' +
60
- outputRange.length +
61
- ') must have the same length',
62
- );
52
+ if (__DEV__) {
53
+ checkInfiniteRange ( 'outputRange' , outputRange ) ;
54
+ checkInfiniteRange ( 'inputRange' , inputRange ) ;
55
+ checkValidInputRange ( inputRange ) ;
56
+
57
+ invariant (
58
+ inputRange . length === outputRange . length ,
59
+ 'inputRange (' +
60
+ inputRange . length +
61
+ ') and outputRange (' +
62
+ outputRange . length +
63
+ ') must have the same length' ,
64
+ ) ;
65
+ }
63
66
64
67
const easing = config . easing || linear ;
65
68
@@ -276,16 +279,10 @@ function findRange(input: number, inputRange: $ReadOnlyArray<number>) {
276
279
277
280
function checkValidInputRange ( arr : $ReadOnlyArray < number > ) {
278
281
invariant ( arr . length >= 2 , 'inputRange must have at least 2 elements' ) ;
282
+ const message =
283
+ 'inputRange must be monotonically non-decreasing ' + String ( arr ) ;
279
284
for ( let i = 1 ; i < arr . length ; ++ i ) {
280
- invariant (
281
- arr [ i ] >= arr [ i - 1 ] ,
282
- /* $FlowFixMe[incompatible-type] (>=0.13.0) - In the addition expression
283
- * below this comment, one or both of the operands may be something that
284
- * doesn't cleanly convert to a string, like undefined, null, and object,
285
- * etc. If you really mean this implicit string conversion, you can do
286
- * something like String(myThing) */
287
- 'inputRange must be monotonically non-decreasing ' + arr ,
288
- ) ;
285
+ invariant ( arr [ i ] >= arr [ i - 1 ] , message ) ;
289
286
}
290
287
}
291
288
0 commit comments