Skip to Content
Docs03 TypeScript

TypeScript essentials (what you need for this stack)

TypeScript helps us express data shapes, prevent whole classes of bugs, and make refactors safe. It does not replace runtime validation (we use Zod for that).

Use these sources (in order)

What “good” looks like

  • Use types to model domain data (not just “make the compiler happy”).
  • Prefer unknown over any at boundaries.
  • Use narrowing (typeof, in, predicates) to make unsafe data safe.
  • Avoid over-abstracting with generics; keep it readable.

Where it shows up in our stack

  • React: props and component state
  • Zod: z.infer<typeof schema> for shared types
  • tRPC: end-to-end typing for procedure inputs/outputs
  • Tests: typed factories and helpers

Exercises (planned)

  • Refactor a JS utility to typed TS + Vitest tests.
  • Model procedure inputs/outputs and remove any from a feature.
Last updated on