Skip to Content
Effective TypeScript
book

Effective TypeScript

by Dan Vanderkam
October 2019
Intermediate to advanced
261 pages
6h 14m
English
O'Reilly Media, Inc.
Book available
Content preview from Effective TypeScript

Chapter 8. Migrating to TypeScript

You’ve heard that TypeScript is great. You also know from painful experience that maintaining your 15-year-old, 100,000-line JavaScript library isn’t. If only it could become a TypeScript library!

This chapter offers some advice about migrating your JavaScript project to TypeScript without losing your sanity and abandoning the effort.

Only the smallest codebases can be migrated in one fell swoop. The key for larger projects is to migrate gradually. Item 60 discusses how to do this. For a long migration, it’s essential to track your progress and make sure you don’t backslide. This creates a sense of momentum and inevitability to the change. Item 61 discusses ways to do this.

Migrating a large project to TypeScript won’t necessarily be easy, but it does offer a huge potential upside. A 2017 study found that 15% of bugs fixed in JavaScript projects on GitHub could have been prevented with TypeScript.1 Even more impressive, a survey of six months’ worth of postmortems at AirBnb found that 38% of them could have been prevented by TypeScript.2 If you’re advocating for TypeScript at your organization, stats like these will help! So will running some experiments and finding early adopters. Item 59 discusses how to experiment with TypeScript before you begin migration.

Since this chapter is largely about JavaScript, many of the code samples are either pure JavaScript (and not expected to pass the type checker) or checked with looser settings (e.g., with ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Effective TypeScript, 2nd Edition

Effective TypeScript, 2nd Edition

Dan Vanderkam
Understanding TypeScript

Understanding TypeScript

Maximilian Schwarzmüller
Learning TypeScript

Learning TypeScript

Josh Goldberg

Publisher Resources

ISBN: 9781492053736Errata Page