A quick example around assertions and type predicates 👇
In the example below, the filtered result gets inferred as (string | undefined), even tho the condition is correctly filtering undefined values
In that case, you could either apply an "as" assertion on the entire result or apply a type predicate within the condition