This is not a general replacement for `.length > 0`<!-- -->, since it is also a typeguard: `if (hasItems(val)) else { val }` will complain that `val` is `never` in the `else` branch, since it was proven not to be an array by this function, even if `val` is simply empty.