New series: what assistive tech really hears on your checkout page. Start with part one →
Shipwright
Home
TypeScript Jul 24, 2026 2 min read 197 views

Generics in Ten Minutes

June Park

June Park

@junepark

Share
Cover illustration for the article Generics in Ten Minutes

A short screencast building a typed fetch helper one generic at a time. TypeScript is at its best when you barely notice it. The goal of this post is fewer annotations, not more, while catching the bugs that actually reach production.

Sample footage: Sintel, an open movie by the Blender Foundation, released under a Creative Commons licence.

Let inference do the work

Inference covers most local code. Annotate function parameters and public return types, and let the compiler fill in everything else. If you find yourself writing as, stop and ask which check is missing.

  • Annotate parameters and exported return types.
  • Validate external data once, at the edge.
  • Prefer discriminated unions over optional flags.
  • Treat every as cast as a code smell to review.

Data that crosses a boundary, whether a network response, a form, or a query string, is untrusted until something validates it at runtime. Types alone cannot do that job, but they can make sure validation happens once.

Questions, corrections, and war stories are welcome in the comments. Several of our best follow-up posts started as a reader pointing out something we had missed.

We will revisit this in six months with fresh numbers. If the results change, we will update the post and note what changed at the end.

If you try this on your own project, start with one page or one service rather than the whole codebase. A small experiment gives you real numbers to argue with, and it is easy to roll back if the idea does not fit.

We have been running this approach for several months now. The initial setup took about a day, and the ongoing cost is close to zero once the team knows where to look.

Program testing can be used to show the presence of bugs, but never to show their absence!

Edsger W. Dijkstra, Notes on Structured Programming, 1970

June Park

June Park

Author

Frontend engineer working across React and TypeScript. June writes the posts she wishes she had found while debugging.

Related Posts

Comments 7

Kofi Mensah

This is exactly the write-up I needed this week. We hit the same wall last sprint.

Lena Novak

This finally clicked for me after reading the docs three times.

June Park Author

Agreed. Start simple and only reach for this when you feel the pain.

Amara Nwosu

Safari 16.4 and newer are fine in our testing; older versions need the fallback line.

Amara Nwosu

We run this in production at a fairly large scale and can confirm the caveats are real.

Amara Nwosu

It should work without shell access, you just lose the command-line shortcuts.

Diego Alvarez

Any thoughts on how this interacts with server-side rendering?

Leave a comment

Your email will not be published. Sign in for a faster experience.

Supports **bold**, *italic*, and `code`.