finds.dev← search

// the find

bcherny/flow-to-typescript

★ 437 · TypeScript · MIT · updated Dec 2022

Convert Flow-annotated files to TypeScript

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.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →