@@ -716,6 +716,7 @@ let rec push_negation (e : t) : t option =
716
716
717
717
- [(typeof x === "boolean") && (x !== true/false)] -> unchanged
718
718
- [(typeof x === "boolean" | "string" | "number") && (x !== boolean/null/undefined)] -> [typeof x === ...]
719
+ - [(Array.isArray(x)) && (x !== boolean/null/undefined)] -> [Array.isArray(x)]
719
720
720
721
Note: The function preserves the semantics of the original expression while
721
722
attempting to reduce it to a simpler form. If no simplification is possible,
@@ -862,6 +863,24 @@ let rec simplify_and (e1 : t) (e2 : t) : t option =
862
863
when Js_op_util. same_vident ia ib ->
863
864
(* Note: case boolean / Bool _ is handled above *)
864
865
Some {expression_desc = typeof; comment = None }
866
+ | ( (Call
867
+ ( {expression_desc = Str {txt = " Array.isArray" }},
868
+ [{expression_desc = Var ia}],
869
+ _ ) as is_array),
870
+ Bin
871
+ ( NotEqEq ,
872
+ {expression_desc = Var ib},
873
+ {expression_desc = Bool _ | Null | Undefined _} ) )
874
+ | ( Bin
875
+ ( NotEqEq ,
876
+ {expression_desc = Var ib},
877
+ {expression_desc = Bool _ | Null | Undefined _} ),
878
+ (Call
879
+ ( {expression_desc = Str {txt = " Array.isArray" }},
880
+ [{expression_desc = Var ia}],
881
+ _ ) as is_array) )
882
+ when Js_op_util. same_vident ia ib ->
883
+ Some {expression_desc = is_array; comment = None }
865
884
| _ -> None
866
885
867
886
(* *
0 commit comments