Porting 100K lines of code to TypeScript
summary
TinyMCE converts roughly 100k lines of JS to TypeScript using an AST-based conversion script that rewrites AMD modules to ES2015, pulls module bodies to the top level and emits export default any so the code compiles immediately. The team does the migration library-by-library (around a hundred libs), runs a test harness that runs TSC and npm test across all repos, and finishes the bulk in about a month. Result: caught real bugs (accidental global from commented ctor args, mismatched function-arg bug), gained automated refactoring and compile-time checks, and continues adding stricter flags and an API .d.ts surface via gradual typing.
AI-written summary · about
chapters (14)
- 0:00Intro
- 4:14Motivation for the Conversion Project
- 5:08Why TypeScript?
- 7:50What is Gradual Typing?
- 8:49Conversion Process for each Library
- 10:27The Conversion Script
- 12:32Module Conversion Example
- 13:48Adding Types
- 16:35Example Bugs
- 22:39Convert Common Libraries First
- 24:15Gradually introduce Compiler Features
- 26:02Write a Script to Test Everything
- 28:30Developer Adjustments
- 30:28Continuing Work
related talks
31mJavaScript That Scales
26mPorting Web SDK from JS into TS
35mTypeScript at Google
26mAdopting Typescript at Scale
24mTypeScript and how I've learned to love the compiler
27mLessons Learned Converting Snyk Codebase to TypeScript
22mMigrating 600k+ Lines of Code from Flow to TypeScript
49mModern TypeScript is amazing!
