TypeScript course

TypeScript Level 13: Testing & Refactoring

Testing & Refactoring is level 13 of 16 of the LoWisa TypeScript course. It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

Updated 2026-11-16

Testing Typed Code

  • Types are not tests. Types prove shapes, tests prove behaviour: a perfectly typed function can still compute the wrong number.
  • Typed test doubles. Build fakes that satisfy the real interface: the compiler keeps stubs honest when the contract moves.
  • Type-level tests. Assertions like expectTypeOf pin your public types themselves, catching accidental signature breaks.

Type-Safe Refactoring

  • Lean on the compiler. Change the type first and follow the errors: the compiler hands you the complete, ordered TODO list.
  • Rename and reshape. Symbol rename and signature changes ripple safely through a typed codebase in one operation.
  • Strangling any. Refactor legacy by shrinking any: each one replaced with a real type turns invisible risk into checked code.

Maintaining Large TypeScript Codebases

  • Type-check in CI. CI runs tsc on every change: a red type check blocks the merge exactly like a failing test.
  • Build performance. Large repos keep checking fast with incremental builds and project references: slow checks get skipped, then trusted.
  • Upgrading the compiler. Compiler upgrades tighten inference: schedule them, read the changelog, and fix what new strictness reveals.

Before and after this level

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.

Frequently asked questions

What does TypeScript Level 13: Testing & Refactoring cover?

Testing Typed Code, Type-Safe Refactoring, Maintaining Large TypeScript Codebases: 3 lessons and 9 ideas.

What should I know before this level?

The level before it, Level 12: Error Modelling, which covers Typed Results and Errors, Exhaustiveness, Designing Impossible States Out.

Learn TypeScript on your phone

The first level is free. LoWisa is on Google Play and the App Store.