File tree 1 file changed +6
-0
lines changed
crates/oxc_minifier/src/peephole
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,10 @@ impl<'a> PeepholeOptimizations {
290
290
}
291
291
// Only convert integers for other radix values.
292
292
let value = lit. value ;
293
+ if value. is_infinite ( ) {
294
+ let s = if value. is_sign_negative ( ) { "-Infinity" } else { "Infinity" } ;
295
+ return Some ( ctx. ast . expression_string_literal ( ce. span , s, None ) ) ;
296
+ }
293
297
if value. is_nan ( ) {
294
298
return Some ( ctx. ast . expression_string_literal ( ce. span , "NaN" , None ) ) ;
295
299
}
@@ -1427,6 +1431,8 @@ mod test {
1427
1431
test ( "x = NaN.toString()" , "x = 'NaN';" ) ;
1428
1432
test ( "x = NaN.toString(2)" , "x = 'NaN';" ) ;
1429
1433
test ( "x = Infinity.toString()" , "x = 'Infinity';" ) ;
1434
+ test ( "x = Infinity.toString(2)" , "x = 'Infinity';" ) ;
1435
+ test ( "x = (-Infinity).toString(2)" , "x = '-Infinity';" ) ;
1430
1436
test ( "x = 1n.toString()" , "x = '1'" ) ;
1431
1437
test_same ( "254n.toString(16);" ) ; // unimplemented
1432
1438
// test("/a\\\\b/ig.toString()", "'/a\\\\\\\\b/ig';");
You can’t perform that action at this time.
0 commit comments