finds.dev

bcherny/flow-to-typescript

Convert Flow-annotated files to TypeScript

View on GitHub

★ 437TypeScriptMITupdated Dec 2022

// the take

This is a CLI and library that rewrites Flow type annotations as TypeScript, with one rule file per Flow construct. It is for people migrating a Flow codebase who want a mechanical first pass before fixing the rest by hand. The README still calls it pre-alpha, and the last push was in December 2022.

- Each conversion lives in its own file under src/rules, with a matching input/output fixture pair under test/rules. You can see exactly what a given Flow form becomes, and adding a new one doesn't touch the others.

- The e2e fixtures run whole files (flow-react, flow-dom), not just isolated snippets, so the test suite covers realistic input rather than only the cases the author thought of.

- The README table states what cannot be expressed in TypeScript, such as opaque types and %checks predicates, instead of silently converting them. That is the right instinct for a migration tool.

- The README table disagrees with the tree. $Keys has a rule file and fixture but is left unchecked, while $Values, $Diff, $ObjMap and $TupleMap are blank or TODO. From the README alone you can't tell what works.

- Some conversions lose meaning. $Supertype and the existential type `*` become `any`, and opaque types become plain aliases, so the encapsulation is gone. The output compiles but checks less than the original.

- Nothing has been pushed since December 2022, and newer Flow syntax is probably unhandled. Anyone adopting this should expect to maintain a fork or finish the rules themselves.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
437
Forks
40
Language
TypeScript
License
MIT
Last commit
6 Dec 2022

// nearby

If flow-to-typescript isn't quite it.

All repos →