It's surprisingly robust and non-lossy as it stands right now, in big part thanks to how similar flow and typescript definition files are. Please see the output in this flow-typed PR for the state of the output.
npm i flowgen --save
Recommended second step:
;// Make the definition human readableconst readableDef = ;
Standard usage (will produce
npm i -g flowgenflowgen lodash.d.ts
-o / --output-file [outputFile]: Specifies the filename of the exported file, defaults to export.flow.js
--flow-typed-format: Format output so it fits in the flow-typed repo--compile-tests: Compile any sibling <filename>-tests.ts files found
Namespaces have been a big headache. What it does right now is that it splits any namespace out into prefixed global scope declarations instead. It works OK, but its not pretty and there's some drawbacks to it.
Definitions in TS and flow are often quite different, and imported types from other libraries dont usually have
a one-to-one mapping. Common cases are
This might require manual processing, or we add a set of hardcoded mutations that handle common cases.
Lodash has been one of the reference libraries i've worked with when creating the converter. The definition is mostly just a series of interfaces with the same name being re-declared over and over again for each function, which doesn't translate to flow at all. There's multiple ways of solving this but I dont have a great solution for it in place yet.
All help is appreciated. Please tweet at me if you want some help getting started, or just want to discuss ideas on how to solve the trickier parts.