How We Migrated 2M Lines of TypeScript to Strict Mode in 6 Months
Stripe enabled strict TypeScript across 2M lines of code in 6 months using incremental codemods, CI guardrails, and developer buy-in — reducing type-related bugs by 38%.
핵심 요점
They used a custom codemod pipeline that transformed ~400 files per week automatically, with a human review step only for edge cases. The key insight was making strict mode opt-in per directory, not per file.
CI was configured to block any new code that didn't pass strict checks, creating a one-way ratchet. Teams could migrate at their own pace, but could never regress. This prevented the 'boiling frog' problem.
Post-migration metrics showed a 38% reduction in type-related production incidents and a 15% improvement in IDE autocompletion accuracy, which the team measured as a proxy for developer velocity.
전체 요약
Stripe's TypeScript monorepo had grown to over 2 million lines of code across hundreds of packages, but strict mode had never been enforced globally. The result was a patchwork of type safety — some packages were strict, others relied heavily on `any` types and implicit conversions that masked real bugs.
The migration team (3 engineers, part-time) started by building a dependency graph of all internal packages and identifying leaf nodes — packages with no internal dependents. These were migrated first using automated codemods that handled the most common patterns: adding explicit return types, replacing `any` with `unknown`, and fixing nullable access patterns.
The codemod pipeline processed approximately 400 files per week. Each batch went through automated testing, then a lightweight human review focused on semantic correctness rather than syntax. The team found that 92% of transformations were correct on the first pass.
The critical infrastructure decision was the CI ratchet: once a directory was marked as strict-compatible, any PR that introduced a strict-mode violation would fail CI. This prevented regression and created natural pressure for teams to migrate their own code proactively.
By month 4, momentum had shifted from push to pull — teams were requesting migration support rather than resisting it, largely because the IDE experience in strict packages was noticeably better. Auto-imports worked more reliably, refactoring tools caught more issues, and code review became faster.
The final metrics were compelling: 38% fewer type-related production incidents, 15% improvement in IDE autocompletion accuracy (measured via internal telemetry), and a measurable reduction in PR review cycles for strict packages. The team estimates the migration paid for itself within 3 months of completion.
전체 내용이 필요하신가요?
Stripe Engineering 에서 원문 읽기 — 코드 샘플, 다이어그램, 더 깊은 맥락을 확인하세요.