Image for post
Image for post

Migrating from Flow to Typescript

Experiences with migrating a small library

Why migrate to TypeScript?

I recently wrote a post about how I tried out FlowType only to feel a little less enthusiastic about it by the end.

Image for post
Image for post
A genetic algorithm in action

Migration Experience

No more Babel

In my previous post on Flow one of the reasons for not immediately flocking towards TypeScript was because TypeScript is a self-proclaimed superset of Javascript.

Image for post
Image for post
package.json

Config differences

My old .flowconfig file was minimal to begin with.

Syntactical differences

One of the really great parts about this migration is how incredibly similar the syntax is between these two type solutions. I was able to convert everything to TypeScript within 90 minutes, including usages of union types and generics, and that was with only having mild familiarity of TypeScript to begin with.

Image for post
Image for post
hello.world.js (flow)
Image for post
Image for post
hello.world.ts

Type checker differences

The only differences I could possibly comment on are potential type errors that TypeScript’s compiler would have caught that Flow’s didn’t. There are likely other differences but since I already wrote the project in Flow most of my potential type errors were already eliminated.

Image for post
Image for post
Image for post
Image for post

Error message differences

One of my biggest gripes with Flow was its jarring error messages. Here’s an example again from my last post.

Image for post
Image for post
Image for post
Image for post

Problems

The only problem worth reporting is that VSCode’s Intellisense wasn’t working unless the version of TypeScript in the project matched exactly the version of TypeScript that VSCode uses.

Community

Lastly, I think it’s worth mentioning community. The fact is TypeScript is noticeably moving forward more quickly than Flow and it’s building up a community as it goes.

Is TypeScript better than Flow?

Let’s be clear about something. This post is insufficient to answer that question.

Written by

Advocate of technology and techniques that move the tech industry forward

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store