~ pardon the mess ~

Our farm is under construction.

We're rebuilding fences, painting barns, and teaching the sheep new tricks. Some pages may be a bit dusty — check back next week for the full opening.

Arun Negi
✉ Get in touch
Home  ›  Watch  ›  CityJS New Delhi · 2024
Now playing 🐑

TypeScript at Scale:
Patterns That Don't Break in Year Three

08:30/30:24
CityJS New Delhi2024★ Featured

TypeScript at Scale:
Patterns That Don't Break in Year Three

How to structure TypeScript in a codebase that grows past the point where 'just add a type' stops working. Covers discriminated unions, branded types, and module boundaries.

30:24CityJS New Delhi2024TypeScriptArchitecture

jump toChapters

1

The scale problem

Why most TS patterns break after year two.
00:00
2

Discriminated unions

The pattern I reach for first, every time.
08:30
3

Branded types

Type-safe IDs that prevent entire bug classes.
15:44
4

Module boundaries

Where to draw the lines in large codebases.
22:10
5

Q&A

Audience questions, some very hard ones.
27:30
Speaker's NoteBy CityJS New· 6 min read

How we built TypeScript at Scale — and what I got wrong the first time.

This talk came from eighteen months of watching a mid-size codebase slowly become impossible to refactor. Not because the developers were bad — they were excellent — but because the TypeScript patterns they'd chosen in year one had invisible load-bearing assumptions that broke under team growth. What follows is what we changed, and why.

The talk ended up being about three things at once: the patterns themselves, the team dynamics that make you need them, and the moment you realise your types are doing work you should be doing in product design. That third thing surprised me when I found it during prep.

“Half of the type errors we fixed were symptoms. The real problem was that the data model didn't match the domain.”
TypeScriptArchitecture

Transcript  — click a timecode to jump

ARUN:Right. Let's talk about what happens when TypeScript gets big.
ARUN:In year one, you add types to your JavaScript. In year two, you fix the any. In year three, you realise the types were all wrong to begin with.
ARUN:Discriminated unions. Specifically: every non-trivial state machine in your app should be one.
ARUN:UserId is not a string. It's a branded string — and that distinction saves you from an entire class of runtime bugs the compiler would otherwise miss.
ARUN:Module boundaries are where most teams give up. I want to talk about why, and what to do instead.
Q:How do you handle branded types across API boundaries — serialisation and deserialisation?
ARUN:Great question. You validate at the edge. Zod, or a type guard. Inside the boundary everything is already branded — you trust it.
straight from the channel

More Episodes.

View all episodes →
YouTube
30:24

TypeScript at Scale: Patterns That Don't Break in Year Three

CityJS New Delhi·2024
YouTube
25:00

Design Systems Without the Ceremony

ReactIndia 2024·2024
YouTube
20:00

The Multi-Persona Web

Delhi JS Meetup·2025