Migrating Millions of Lines of Code: From Flow to TypeScript

TLDRStripe successfully migrated millions of lines of code from Flow to TypeScript, implementing an automated conversion tool and ensuring a smooth transition for engineers.

Key insights

⚡️Stripe migrated over 3.7 million lines of code from Flow to TypeScript in a single pull request, showcasing the scale of the conversion.

📚The team at Stripe used Airtable's conversion script as a basis for their migration efforts, taking advantage of the open source community's contributions.

🚀By generating TypeScript definitions for their shared design system, Stripe was able to support applications written in both Flow and TypeScript without major code changes.

🔁Handling syntactic and semantic edge cases, such as arrow functions with generic arguments, required iterative improvements to the conversion tool.

🛠Stripe's focus on internal tools and developer experience led to the formation of a JavaScript infrastructure team dedicated to enhancing the JS ecosystem within the company.

Q&A

How did Stripe handle the tight coupling between components in their codebase during the migration?

Stripe opted for an all-at-once migration strategy, which allowed them to achieve a clean break between Flow and TypeScript and avoid the complexities of an incremental migration.

Did Stripe face any challenges during the migration from Flow to TypeScript?

Stripe encountered challenges related to syntactic and semantic edge cases, which required iterative improvements to the conversion tool. However, their focus on developer experience and internal tooling helped them overcome these challenges.

What impact did the migration have on Stripe's development environment and engineering productivity?

The migration to TypeScript significantly improved Stripe's development environment and engineering productivity. Engineers no longer needed to work with both Flow and TypeScript, resulting in a reduced cognitive overhead and a more streamlined coding experience.

How did Stripe ensure consistent and reliable TypeScript definitions for their shared design system?

Stripe generated TypeScript definitions for their shared design system, enabling support for applications written in both Flow and TypeScript. They also wrote tests to ensure the accuracy and consistency of the definitions.

What lessons can other companies learn from Stripe's migration from Flow to TypeScript?

Companies considering a similar migration should leverage open source contributions and community resources, like the conversion script provided by Airtable. Additionally, prioritizing internal tooling and developer experience can greatly facilitate a successful transition.

Timestamped Summary

00:00Stripe successfully migrated millions of lines of code from Flow to TypeScript, implementing an automated conversion tool and ensuring a smooth transition for engineers.

02:20Stripe utilized an open source conversion script developed by Airtable as a foundation for their migration efforts.

03:59By generating TypeScript definitions for their shared design system, Stripe was able to support applications written in both Flow and TypeScript without major code changes.

09:29Iterative improvements were made to the conversion tool to handle syntactic and semantic edge cases, ensuring accurate and reliable migration results.

06:11The creation of a dedicated JavaScript infrastructure team at Stripe highlights their commitment to enhancing the developer experience and internal tooling.