[new-generics] Codemod to add annotations to prevent escaped generics
[new-generics] Codemod to add annotations to prevent escaped generics

Summary:
This diff creates a codemod to add type annotations to unannotated variables that receive escaped generics. The structure of this diff mostly follows `src/facebook/komodo/codemods/suggest.ml`, but uses the same `Hardcoded_Ty_Fixes` as the annotate-exports codemod. Annotations are inserted via a visitor that traverses the AST and finds the locations pointed to by the `annot_reason` field of `EEscapedGeneric` error messages (the reason for the missing annotation that caused the generic to escape into a tvar). It then writes the normalized type of the tvar out as an annotation.

Unfortunately the resulting programs still can have errors: we sometimes generate unions that speculation can't distinguish, and the codemod as written doesn't know how to add new type exports to external modules when they contain type definitions needed in clients. In testing on xplat, though, this was sufficient to fix most escaped-generic errors without introducing any new errors (see D22799686)

Reviewed By: panagosg7

Differential Revision: D21775142

fbshipit-source-id: d7675b4b07598639bca20b1219ab209892ed585c

facebook/flow,facebook/flow,facebook/flow,mroch/flow,facebook/flow,mroch/flow,mroch/flow,mroch/flow,facebook/flow,mroch/flow,facebook/flow,facebook/flow,mroch/flow,mroch/flow