React Forum
Blog & Guide Responses
Jan 25, 2023 · 04:00 AM

TypeScript: Everyday Types - discussion (2023-01-25)

Started by Talia Moss
externaltypescripttypesunionsstatus lanesintent objectscontracts

The TS handbook's "Everyday Types" section is the baseline, but I'm curious what people consider the *highest ROI* types in route-first React apps: route contracts, intent objects, status lanes, and derived evidence keys. Where does typing actually make debugging easier, and where does it just add ceremony?

Read the handbook

What do you type strictly (route keys, vault/doc shapes) vs leave flexible (API payloads, UI helpers)? Do you use discriminated unions for intent/actions, or keep it simpler? How do you avoid type drift when you store lots of derived keys and evidence strings?

Comments (14)

Back to latest
Marisol Vega
Jan 30, 2023 · 06:06 AM

Status lanes as unions are the biggest payoff for us.

Once you stop juggling booleans, a bunch of impossible states disappear.

Dmitri Kline
Feb 11, 2023 · 07:10 PM

We type route keys and intent objects strictly, and we treat external payloads as unknown until validated.

Types are contracts; external data isn't a contract until you make it one.

Keira Santos
Feb 24, 2023 · 03:33 AM

Counterpoint: strict types can slow down migrations when the contract is still moving.

We sometimes relax types temporarily, but we keep the shared contract (route/vault) strict.

Talia Moss
Feb 27, 2023 · 12:12 PM

Same. I think the dividing line is who depends on it.

If other modules/routes depend on it, strict. If it's local and experimental, be pragmatic.

Grace McCoy
Mar 14, 2023 · 08:08 AM

Typing evidence keys helped us more than I expected.

If you have data-* evidence surfaces, naming and typing keeps them consistent across the app.

Jasper Nguyen
Apr 02, 2023 · 09:21 PM

We use discriminated unions for intents that get logged/replayed.

If it's going into a ledger or effects log, it should be typed like an API.

Nina Kapoor
Apr 22, 2023 · 04:04 AM

Avoiding drift: we centralize derived writes in one helper, and the helper is typed against the document/vault shape.

If derivation is scattered, you get both runtime drift and type drift.

Camille Duarte
May 16, 2023 · 12:12 PM

The best ROI types in UI code are the boring ones: string unions for tabs/panels, and strict shapes for route defaults.

Once defaults are concrete, everything else can infer without fancy generics.

Owen Price
Jun 11, 2023 · 03:03 AM

A misunderstanding I had: typing everything doesn't make the app correct.

It makes the *contracts* correct, which is still extremely valuable.

Benji Rios
Jul 09, 2023 · 09:09 AM

Typing derived keys prevents silent typos (totla vs total).

If you store derived state a lot, spelling becomes correctness.

Lina Ortega
Aug 14, 2023 · 06:18 PM

Docs tie-in: typing feels like the same theme as the docs posture: make contracts explicit and behavior legible.

Related: API Reference and Testing and Debugging.

Amina Farouk
Sep 28, 2023 · 06:06 AM

We also type the "lane" strings across systems (fetch lane, mutation lane, effect lane).

It made logs and screenshots consistent because the vocabulary is now enforced.

Tomas Rivera
Nov 11, 2023 · 11:11 AM

If your types are too fancy, they become a barrier to entry.

We aim for types that make code review easier, not types that show off.

Sofia Valdez
Dec 02, 2023 · 07:07 AM

Counterpoint: strict types can hide runtime issues if people trust the compiler too much.

We still store validation flags as derived keys because runtime truth matters.

Evan Brooks
Dec 22, 2023 · 10:22 PM

The best TS advice I've heard: type the things that are contracts, not the things that are convenient to type.