Files
test-repo/tests/flow/intersection/test_fun.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

32 lines
743 B
JavaScript

/**
* Tests for intersections of function types.
*
* Note: Flow abuses intersection types to model
* function overloading, which precludes using a
* correct intersection of return types in the result.
*
* Here we test the special case where return types
* are equal. Tests of the overloading behavior can
* be found in tests/overload
*
* Definitions lin lib/lib.js
*
* @noflow
*/
// intersection of function types satisfies union of param types
type F = (_: ObjA) => void;
type G = (_: ObjB) => void;
type FG = (_: ObjA | ObjB) => void;
declare var fun1 : F & G;
(fun1 : FG);
var fun2 : FG = fun1;
// simpler variation
declare var f : ((_: number) => void) & ((_: string) => void);
var g: (_: number | string) => void = f;