AP3
All topics

Product states / making ambiguous states explicit

TypeScript Fundamentals

Model the product clearly enough that invalid states become difficult to express.

Why this matters

TypeScript is the connective tissue between interface intent and runtime truth. Fluency here makes loading, access, failure, data contracts, and server boundaries part of the product model instead of cleanup after the UI is drawn.

Concepts to learn

  • Types, interfaces, unions, and narrowing
  • Discriminated unions for product states
  • Generics and reusable contracts
  • Async code and typed error handling
  • Runtime validation at external boundaries
  • Typed API contracts and server/client boundaries
  • Nullability, permissions, and entitlement modeling

Apply It in Casset

Casset is the working environment for this skill—not the curriculum itself.

  • Give ShelfSurface a finite state model—loading, ready, empty, unavailable, and error—instead of collapsing every request failure into an empty shelf.
  • Trace one value from the database through the public API, SDK validation, Artist Runtime projection, React host, and rendered interface.
  • Audit unsafe casts and ambiguous nullable values around the canonical Casset App permission and fan-entitlement vocabulary.
  • Add or strengthen runtime validation where data crosses an external boundary; preserve the existing Track Runtime owner rather than introducing a parallel contract.

Suggested project

Runtime state atlas

Document and implement the state model for one Casset surface from server response to visible recovery.

Open project notebook

Evidence of completion

These are completion conditions, not claimed achievements. Each stays planned until it links to a real artifact or verification.

  • implementationOne production-facing surface expressed as an exhaustive state machineplanned
  • testsTests for valid, degraded, unauthorized, and impossible statesplanned
  • diagramDatabase → API → SDK → runtime → UI contract diagramplanned
  • reflectionA short note on which ambiguities the type system exposedplanned

Open questions

  • Which states belong in shared contracts, and which should remain local to a surface?
  • Where does runtime validation add safety without duplicating the compiler?

Related notes

Books, talks, and useful things

  • book
    Effective TypeScriptDan Vanderkam
  • tool
    TypeScript HandbookMicrosoft

    Use it as a reference beside live product work.

Reflection journal

A type is useful when it changes the interface decision, not merely when it satisfies the compiler.