@@ -716,6 +716,7 @@ let rec push_negation (e : t) : t option =
716716
717717 - [(typeof x === "boolean") && (x !== true/false)] -> unchanged
718718 - [(typeof x === "boolean" | "string" | "number") && (x !== boolean/null/undefined)] -> [typeof x === ...]
719+ - [(Array.isArray(x)) && (x !== boolean/null/undefined)] -> [Array.isArray(x)]
719720
720721 Note: The function preserves the semantics of the original expression while
721722 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 =
862863 when Js_op_util. same_vident ia ib ->
863864 (* Note: case boolean / Bool _ is handled above *)
864865 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 }
865884 | _ -> None
866885
867886(* *
0 commit comments