This is part of a series on gradual TypeScript migration. You can find a list of all the posts in the series here.
In short: I am gradually migrating a large codebase to use TypeScript. The decision to migrate gradually doesn’t make sense without some context, and this post has that context.
Plenty of other companies have adopted TypeScript in their codebases. Adoptability is one of the core appeals of TypeScript. Lots of places have painted pictures of what migrating their site to TypeScript looks like. Notably, AirBnB migrated all of their files to TypeScript at once, added comments to ignore any compilation errors, and gradually improved their types over time. This strategy essentially allowed them to adopt the language quickly while deferring the benefits of strongly-typed code, which is a reasonable trade-off.
There are a few ingredients that makes this particular migration different:
While some people are familiar with TypeScript, that isn’t yet true for most of our engineering org. People were pretty eager for ES6+ syntax because almost everyone had been using it at their old jobs or in their bootcamps. The same isn’t true with TypeScript; only a handful of people have experience with it.
Like every e-commerce site, everyone in the product org is heads-down on holiday season work.
Our team has something of a code freeze on any infrastructure work we’d be doing otherwise.
To me, this means that I have a month or two of time to spend preparing our codebase for TypeScript, as long as I do it in a way that doesn’t make people’s jobs difficult. Once the busy season cools off for product engineering, it’ll be easier to convince people to start adding types to all of the projects they’re working on. This probably means that AirBnB’s “all-at-once” strategy is off the table, at least for now.
In addition, not everywhere is AirBnB. These notes will hopefully help others decide what migration strategy works best for them.
The migration plan is essentially this:
With any luck, enough of the tools that product engineers most commonly reach for will be TypeScript-ified shortly after the holiday season ends, and in the nearer-term, they’ll benefit from some of the things TypeScript can offer to IDEs, like better autocompletion, inline documentation, and deprecation warnings.