CodeStaminaOpen preview

8 exercises · TypeScript · 8–12 min each

TypeScript exercises for judgment, not syntax

Each page is one realistic defect. Predict what the code does, check your answer, then read why the compiler stayed quiet.

Start with impossible states

One defect per page

Every exercise is a single realistic mistake, in code short enough to hold in your head.

Predict before you read

You commit to an answer first. The explanation only lands once you have been wrong on purpose.

No account needed

Read, predict and check without signing in. The workout behind each page is where practice continues.

THE EXERCISES

Start anywhere. They compound in order.

  1. 01

    Discriminated unions: stop modelling impossible states

    Optional properties describe which fields might exist. A discriminated union describes which combinations are allowed — a much stronger claim.

    Data modelling · 8 min
  2. 02

    Exhaustive switches: the default clause that hides new states

    A default clause is a promise that you have thought about every future case. Almost nobody means to make that promise.

    Type narrowing · 8 min
  3. 03

    Missing, empty, zero: three states one falsy check collapses

    if (value) asks whether a value is truthy. Most of the time you meant to ask whether it was provided.

    Data boundaries · 8 min
  4. 04

    Stale async results: when the older request wins

    Requests start in order. Responses do not. Any state update that ignores the difference is a race waiting for a slow network.

    Async state · 12 min
  5. 05

    Retries: the loop that hammers a server it can never satisfy

    A retry is a bet that the same request will behave differently next time. Most failures are not that kind of failure.

    Resilience · 12 min
  6. 06

    Cancellation that stops at the first await

    Accepting an AbortSignal is a promise to stop. Every await you forget to thread it through is a place where you quietly keep going.

    Cancellation · 12 min
  7. 07

    Idempotency: the check-then-act that charges twice

    At-least-once delivery is the normal case, not the edge case. "Have I done this already?" is only a useful question if nobody can answer it at the same time as you.

    Data integrity · 12 min
  8. 08

    Async tests that pass for the wrong reason

    A green async test proves the assertions ran and passed. Plenty of async tests only prove the first half — and some prove neither.

    Test design · 10 min

BEYOND THE READING

Reading about a race condition is not practice.

Each exercise ends in a CodeStamina workout: a specification, a failing test suite and a repair you have to make yourself. One complete guided workout is open without an account.

Open the guided workout

JOIN THE WAITLIST

Help shape what we build next.

Tell us where you want to start and what you want to practise. We’ll use your answers to understand demand and email you about relevant program availability.

What would you like to practise?

We store your email and answers for this waitlist. No campaign is being sent now. Contact mo@codestamina.com to ask us to remove your entry.