š¦ Pinterest Migrated 3.7M Lines to TypeScript. Hereās How They Pulled It Off
A breakdown of Pinterestās tooling, automation, and lessons from rewriting their frontend at scale
In eight months, Pinterest rewrote the backbone of their web infrastructure. Not for fun, but for survival.
They migrated 3.7 million lines of code from Flow to TypeScript in a single coordinated rollout. It was a systemic transformation touching everything from CI pipelines to how internal pages were routed and served.
Letās break down the strategy, the landmines, and what you can steal from their playbook.
šØ TL;DR
Pinterest had used Flow for typed JavaScript since 2016. By 2023, that decision aged out: Flow stagnated, TypeScript won the ecosystem, and hiring Flow developers became painful.
They pulled off the migration using a ābig bangā approach, with aggressive automation, battle-tested codemods, and airtight testing. The result: a better developer experience, faster builds, fewer type bugs and a TypeScript codebase that scales.
Theyāve open-sourced their tools and shared lessons. If youāre still on Flow (or stuck on legacy tech), this is the blueprint.
š§ Why They Chose TypeScript
Pinterest didnāt switch because Flow was broken they switched because TypeScript offered tangible advantages across the board:
Hiring: TS skills are everywhere. Flow? Almost nowhere.
Tooling: TypeScript support in editors, linters, and language servers is miles ahead.
Ecosystem: OSS libraries and community tooling now assume TypeScript.
Language Features: TS supports conditional types, inference tricks, and const assertions that Flow simply doesnāt.
Momentum: Even Meta is leaning more into TypeScript. The writing was on the wall.
Pinterest had achieved 100% Flow coverage, meaning no gradual transition left. It was all or nothing.
Over time, TypeScript became the industryās go-to, a shift clearly visible in its dominance across npm download stats.
Similar posts weāve written in the post on the topic of large scale migrations:
šļø Planning a Big Bang Migration
This project was a structured replacement, one where every file was transformed, tested, and reconnected to the wider ecosystem.
They split the work into three key phases:
Setup ā Get the TypeScript compiler, linters, and build tooling ready
Conversion ā Use codemods to transform Flow syntax to TypeScript
Integration ā Update every system that assumed
.js
, from test runners to internal page routing
Every step had its own edge cases. Every subsystem had assumptions that now broke.
āļø Converting Millions of Lines (Without Going Insane)
Keep reading with a 7-day free trial
Subscribe to Byte-Sized Design to keep reading this post and get 7 days of free access to the full post archives.