— bash — netgod.dev — 80×24
guest@netgod.dev:~/blog$ cat typescript-tips-i-wish-i-knew-earlier.md
← cd ../blog
POST(TYPESCRIPT)netgod.dev manualPOST(TYPESCRIPT)
NAME

$ 10 TypeScript Tips I Wish I Knew Earlier

DESCRIPTION

Discriminated unions, branded types, satisfies — small patterns that make a huge difference once they're in your toolbox.

DATE
2025-03-28
DURATION
1 min read
TAGS
./assets/typescript-tips-i-wish-i-knew-earlier.pngcover
CONTENT

TypeScript rewards investment. The deeper you go, the more the compiler becomes a co-pilot rather than a gatekeeper.

1. Use satisfies

It validates a value against a type without widening it. Perfect for config objects.

2. Branded types

Wrap primitives so a UserId can never be passed where a PostId is expected.

3. Discriminated unions over enums

They model domain states better and play nicely with exhaustive switch checks.

The rest of the list digs into template literal types, conditional types, and the underrated NoInfer helper.

netgod.dev manual2025-03-28END