chore(types): auto-generate types for metro-file-map
Summary
As I began working to hand-fix some types, the formidable @robhogan pointed me in the direction of generateTypeScriptDefinitions.js, which has been used here to generate types for metro-file-map
Changelog:
[Fix]: Auto generate types for metro-file-map
Test plan
Automatically tested in CI, also peformed a good-ol eyeball check.
There are a few failures here, some are easily fixable, others will take some finagling.
1.) IntervalID and TimeoutID, we can simply exclude them with /*:: */ to avoid problems for now, I think the fields wouldn't ever be public anyway.
2.) Incomplete third-party types. For example fb-watchman has types defined in flow-typed. flow-api-translator does NOT play nicely with this.
Option 1: Use @types/fb-watchman
- 😔 these types are less complete than the types in
flow-typed, and leave us with remaining errors. - We could contribute these types back upstream and wait.
Option 2: Some Naive Tooling!
-
flow-api-translatorwill happily convert MOST of those types, but the contents need to be unwrapped from:declare module '{{ moduleId }}' { ...definitions... }. - The
declare module.exports:syntax also needs translation.
[!NOTE] I have a local script that performs these pre-processing steps to be able to successfully generate TS at least for
fb-watchman. It is all naive string matching. Maybe this is fine.
Option 3: Make flow-api-translator "Just Work" This would be neat, but I am unsure if it is worth the investment