Add Flow annotations to escaped generics in xplat

Summary:
Flow will soon stop allowing generic types to "escape" out of the scope in which they were defined. The fix will be to add annotations to currently-unannotated variables, parameters, and function returns, so that generics don't become inputs to type inference for those positions. This diff adds new type annotations to xplat where possible to minimize the impact of this change.

This diff was generated by running
```
buck run //flow/src/facebook/komodo/binaries:annotate_escaped_generics -- --write ../../xplat/js
```
from within the flow directory, and then reverting changes that led to new errors. Most changes were reverted by running:
```
facebook/flowd check --json --json-version=2 ../../xplat/js &> post-json
jq -f j.jq < post-json | xargs hg revert
```
where `j.jq` is
```
def locs: [.primaryLoc.source, (select(.rootLoc.source != null) | .rootLoc.source), .referenceLocs[].source ] | unique;
[.errors[] | locs[]] | unique | .[]
```

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D24006427

fbshipit-source-id: 0cd6ec8a9611d8b1e9b14c54f9fffd2d7de2fd9e
This commit is contained in:
Mike Vitousek
2020-10-01 06:04:59 -07:00
committed by Facebook GitHub Bot
parent 030d2c1931
commit 8f5f3d159b
@@ -30,7 +30,7 @@ import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes';
// Shared by integration tests for ScrollView and HorizontalScrollView
let scrollViewApp;
let scrollViewApp: ScrollViewTestApp | HorizontalScrollViewTestApp;
type ItemProps = $ReadOnly<{|
onPress: (event: PressEvent) => void,