Files
test-repo/tests/flow/predicates-declared/function-union.js
T
Christopher Chedeau 3375cfe605 Move tests around (#454)
* new_tests

* move_all_clobbered_tests

* remove all the tests that no longer exist

* re-run flow tests

* Move all the flow tests to tests/flow and prettier to tests/

* Move prettier tests to their own folders

* Add jsfmt files

* run prettier snapshot tests
2017-01-24 14:35:37 -08:00

19 lines
349 B
JavaScript

// @flow
declare function f1(x: mixed): boolean %checks(typeof x === "string");
declare function f2(x: mixed): boolean %checks(Array.isArray(x));
declare var cond: boolean;
// Feature check:
function foo(x: number | string | Array<string>): number {
var f = (cond) ? f1 : f2;
if (f(x)) {
return x.length;
} else {
return 1;
}
}