// @flow declare function my_filter>(v: Array, cb: P): Array<$Refine>; // Sanity check A: filtering the wrong type declare var a: Array; const b = my_filter(a, is_string); (b: Array); // Sanity check B: Passing non-predicate function to filter declare var c: Array; const d = my_filter(c, is_string_regular); (d: Array); function is_string(x): boolean %checks { return typeof x === "string"; } function is_string_regular(x): boolean { return typeof x === "string"; }