Files
test-repo/tests/flow/destructuring/poly.js
T
Simon Lydell dc93bdc983 Sync the Flow tests (#1163)
* Extract custom tests from tests/flow/

Approach:

1. Remove all .js files in tests/flow except .snap.js files.
2. Copy over all .js files from tests/ in the flow repo.
3. Go through the diff looking for deletions.
   - It was easy to see which deletions were due to changes in the tests
     due to updates in the flow repo.
   - For the rest of the deletions, I used `git blame` to verify that
     they had been added by us since the flow tests were copied over.

This makes tests/flow/ simply a copy of the tests from the flow repo,
making it easier to sync with the upstream flow tests in the future.

* Add a script for syncing the flow tests

* Sync the flow tests
2017-04-08 07:52:38 -07:00

32 lines
867 B
JavaScript

// @flow
function obj_pattern<X>({ prop } : { prop: X }) {} // prop: X
type Prop<X> = { prop: X };
function obj_pattern2<X>({ prop } : Prop<X>) {} // prop: X
function arr_pattern<X>([ elem ] : X[]) {} // elem: X
type Elem<X> = X[];
function arr_pattern2<X>([ elem ] : Elem<X>) {} // elem: X
function tup_pattern<X>([ proj ] : [X]) {} // proj: X
type Proj<X> = [X];
function tup_pattern2<X>([ proj ] : Proj<X>) {} // proj: X
function rest_pattern<X>(...r: X[]) {} // r: X[]
function obj_rest_pattern<X>({ _, ...o } : { _: any, x: X }) { // o: { x: X }
o.x;
}
type ObjRest<X> = { _: any, x: X };
function obj_rest_pattern<X>({ _, ...o } : ObjRest<X>) { // o: { x: X }
o.x;
}
function arr_rest_pattern<X>([ _, ...a ] : [ any, X ]) { // a: [X]
a[0];
}
type ArrRest<X> = [ any, X ];
function arr_rest_pattern<X>([ _, ...a ] : ArrRest<X>) { // a: [X]
a[0];
}