Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Migrating large codebase to TypeScript

Migrating large codebase to TypeScript

It's 2019 and TypeScript is the obvious choice for every new project. But if your codebase is JavaScript how do you make the switch?

Facing a quarter million lines of code – a messy mixture of untyped or poorly flow-typed JavaScript – our team of 15 at productboard absolutely knew we wanted to make the switch, but the barrier to entry looked very high.

A half a year later, 85% of the codebase is strictly typed TypeScript and our confidence over the code has increased tremendously.

In this talk I'd like to share our experience and answer the following questions:

- How we convinced management it was worth the effort?
- How we approached the migration and how we phase it?
- How we learned to best collaborate as a team?
- What we’d do differently next time?

We learned a lot along the way and are eager to share it with all the other teams, because we believe everyone deserves TypeScript!

Avatar for vojta_prikryl

vojta_prikryl

October 25, 2019
Tweet

Other Decks in Programming

Transcript

  1. Vojta Prikryl ! Prague, Czech Republic " Tech Lead in

    productboard @vojta_prikryl @productboard
  2. 1. History & Context 2. How we made the decision

    3. Preparation 4. Initial migration phase 5. Gradual adoption over time 6. Takeaways & Do's & Don'ts Table of Contents
  3. Is TypeScript better than Flowtype?
 Is TypeScript going to be

    better than Flowtype next year?
 Should we migrate now?
  4. Is TypeScript better than Flowtype? • Can it solve our

    pain points? • Features • IDE support
  5. Is TypeScript going to be better than Flowtype next year?

    • Documentation & Project Roadmap
  6. Is TypeScript going to be better than Flowtype next year?

    • Documentation & Project Roadmap • Community activity • Github Issues / Pull requests / Contributors / Commits / ...
  7. Is TypeScript going to be better than Flowtype next year?

    • Documentation & Project Roadmap • Community activity • Github Issues / Pull requests / Contributors / Commits / ...
  8. Is TypeScript going to be better than Flowtype next year?

    • Documentation & Project Roadmap • Community activity • Github Issues / Pull requests / Contributors / Commits / ...
  9. Is TypeScript going to be better than Flowtype next year?

    • Documentation & Project Roadmap • Community activity • Github Issues / Pull requests / Contributors / Commits / ... • 3rd-party Type Definitions
  10. Is TypeScript going to be better than Flowtype next year?

    • Documentation & Project Roadmap • Community activity • Github Issues / Pull requests / Contributors / Commits / ... • 3rd-party Type Definitions
  11. Is TypeScript going to be better than Flowtype next year?

    • Documentation & Project Roadmap • Community activity • Github Issues / Pull requests / Contributors / Commits / ... • 3rd-party Type Definitions
  12. Should we migrate ? now • It's not TS vs

    no-TS (or FlowType) • It's TS vs 100 other ideas what to do
  13. Should we migrate ? now • It's not TS vs

    no-TS (or FlowType) • It's TS vs 100 other ideas what to do • UUID migration, Design System, 
 CSS-in-JS, Optimized data fetching,
 State management improvements, 
 New Features Delivery, etc,...
  14. • What can help us scale as the organization? •

    What will help us the most with onboarding newcomers? Prioritization!
  15. • Migration strategy Flowtype -> TypeScript • Gradual vs Total

    • Didn't want to have 3 technologies next to each other (untyped JS, Flowtyped JS / TS) • People stepping on each others fingers • Migration strategy untyped JS -> TypeScript • How many people to involve? • Decided to work in smaller group of senior engineers with experience with TypeScript in past
  16. • tsconfig • TS / JS interoperability • Build pipeline

    • Babel 7 • Linters • global.d.ts • 3rd Party libs definitions • PoC with Core architectural concepts being typed • in our case State management, HoCs, compose • might be Router, API layer, controller ...
  17. • Learn all features of TypeScript • Read through docs.

    More than once. • Decide how to use some core concepts: • Interface vs Type • Adoption is limited • Our case: • ✅ Enums • ❌ Flux Action Dispatcher
  18. Goals • , Replace Flowtype with TypeScript completely • ❌

    Don't touch untyped JavaScript • - Write internal comprehensive guide • . Be as fast as possible
  19. We survived. But had to explain. Why it took so

    long. After that we earned eternal glory7
  20. Goals • ⏭ Migrate all remaining untyped JavaScript to TypeScript

    • 9 Educate team so everybody can contribute and eventually spread the knowledge
  21. What went well? • Buy-in from both team and management

    • Created great atmosphere in the team. 
 I believe that really helped with the adoption.
  22. Room for improvements? • Preparation • Get even more deeper

    into the technology. • Initial migration got delayed • Communicate better about changing situation