Commit 88a2186
authored
feat(es/minifier): Support unary negate in
**Description:**
Adds support for `-` in `cast_to_number`. Before it only worked if `arg` is `Infinity`. Now it uses a recursive call on `arg` so it works for expressions like `-5`, `-[]` etc.
This change is important because negative number literals (e.g. `-5`) are a `UnaryExpr` with `op`=`-` & `arg`=`5`, unless you apply `expr_simplifier` pass or something else that uses it.cast_to_number (#9642)1 parent 085bc19 commit 88a2186
File tree
2 files changed
+10
-11
lines changed- .changeset
- crates/swc_ecma_utils/src
2 files changed
+10
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
933 | 933 | | |
934 | 934 | | |
935 | 935 | | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
947 | 940 | | |
948 | 941 | | |
949 | 942 | | |
| |||
0 commit comments