1. @khanacademy/flow-to-ts
[![Actions Status](https://github.com/Khan/flow-to-ts/workflows/Node%20CI/badge.svg)](https://github.com/Khan/flow-to-ts/actions) [![codecov](https://codecov.io/gh/Khan/flow-to-ts/branch/master/graph/badge.svg)](https://codecov.io/gh/Khan/flow-to-ts) [![n
@khanacademy/flow-to-ts
Package: @khanacademy/flow-to-ts
Created by: khan
Last modified: Tue, 05 Apr 2022 23:35:13 GMT
Version: 0.5.2
License: MIT
Downloads: 41,297
Repository: https://github.com/khan/flow-to-ts

Install

npm install @khanacademy/flow-to-ts
yarn add @khanacademy/flow-to-ts

flow-to-ts

Actions Status
codecov
npm version

Convert Flow code to TypeScript.

:warning: This is a WIP and many things still do not work properly. There
may also be the odd regression from time to time as work progresses.

The goal of this project is to provide a tool that can translate 95% of Flow
to TypeScript while maintaining a high percentage of the existing type
information. We don't want to convert code and end up with everything using
any. We also want to avoid having to make a lot of manual changes to files
afterwards, e.g. changing SyntheticEvent to React.Event.

Quick start

  • yarn global add @khanacademy/flow-to-ts
  • flow-to-ts [options] <file globs>

For a comprehensive list of available options, please check out the CLI code.

Playground

https://flow-to-ts.netlify.com

Principles

  • when exact translation isn't possible:
    • downgrade to any when possible and provide a gentle warning
    • when it isn't possible to downgrade (e.g. %checks), remove the syntax
      and provide a forceful warning that the code in question will need a human
      to convert it manually.
  • best effort to maintain blank lines and the position comments, this isn't
    always possible so warn in those situations where we can't, e.g. converting
    object type spreads to intersection types.

Contributing

Bugs

Bug reports for converting Flow to TypeScript should include a link to the
playground with an example of a minimal reproducible example of the bug.

Feature Requests

Feature requests are welcome.

Pull Requests

Please make sure there is a GitHub issue first before creating a pull request
except for small things. Also, please sign our Contributor License Agreement.

Pull requests that fix a bug in the conversion code should include one or more
test cases and should have 100% diff coverage.

Dev quick start

 git clone [email protected]:Khan/flow-to-ts.git
cd flow-to-ts
git submodule update --depth 1 --init -- babel
cd babel
yarn
cd ..
yarn
yarn test

Helpful resources

  • https://github.com/niieani/typescript-vs-flowtype
  • https://astexplorer.net/

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code