diff --git a/src/util/null.js b/src/util/null.js index 9150a93..9736fe1 100644 --- a/src/util/null.js +++ b/src/util/null.js @@ -89,5 +89,8 @@ export function orElse(x: ?T, defaultValue: T): T { * in a type-aware way. */ export function filterList(xs: $ReadOnlyArray): T[] { - return (xs.filter((x) => x != null): any); + // A type-safe way to implement this would be: + /*:: (xs.flatMap((x) => x == null ? [] : [x]): T[]); */ + // For performance, we instead take an unsafe route. + return ((xs.filter((x) => x != null): any): T[]); }