TypeScript

TypeScript Advanced #7: Practical patterns and anti-patterns
9 min read

TypeScript Advanced #7: Practical patterns and anti-patterns

Criteria that separate good types from over-typing — any/unknown/never, as const and satisfies, plus the anti-patterns people fall into and how to fix them.

TypeScript Advanced #6: Modules and .d.ts
7 min read

TypeScript Advanced #6: Modules and .d.ts

How to handle and extend the types of external libraries — declaration files (.d.ts), the declare keyword, module augmentation, and adding global types.

TypeScript Advanced #5: Discriminated unions and type guards in depth
4 min read

TypeScript Advanced #5: Discriminated unions and type guards in depth

Modeling for safely handling data of multiple shapes — discriminated unions, user-defined type guards, assertion functions, and branded types.

TypeScript Advanced #4: Template literal types
3 min read

TypeScript Advanced #4: Template literal types

Tools that compose strings at the type level — the `${...}` pattern, Capitalize/Uppercase built-ins, and real-world patterns for modeling route/event names as types.

TypeScript Advanced #3: Conditional types and infer
4 min read

TypeScript Advanced #3: Conditional types and infer

The if statement of the type level — the distributive behavior of T extends U ? X : Y and the patterns that pull values out of a type with infer. Build ReturnType and Awaited yourself.

TypeScript Advanced #2: Mapped types
7 min read

TypeScript Advanced #2: Mapped types

Mapped types that transform an entire object type — how Partial/Required/Readonly are built, plus key remapping (as) and modifiers (+/-).

TypeScript Advanced #1: keyof and typeof
3 min read

TypeScript Advanced #1: keyof and typeof

The two most fundamental tools for building types — using keyof to gather keys, typeof to derive types from values, and the patterns that become possible when they meet.

TypeScript + React in Practice #6: Fetch and API response typing
3 min read

TypeScript + React in Practice #6: Fetch and API response typing

The limits and risks of generic fetchers, and patterns for truly safe handling of external data using zod runtime validation.

TypeScript + React in Practice #5: Context and generic components
3 min read

TypeScript + React in Practice #5: Context and generic components

Type-argument patterns for createContext, a safe useContext helper, and how to build reusable List/Select-like components with generic components.

TypeScript + React in Practice #4: Typing events and forms
3 min read

TypeScript + React in Practice #4: Typing events and forms

What types to use for React event objects and how to type controlled/uncontrolled forms in TypeScript — with practical patterns.

TypeScript + React in Practice #3: Typing hooks
4 min read

TypeScript + React in Practice #3: Typing hooks

How far to leave types to inference and when to be explicit for built-in hooks — useState, useReducer, useRef, useCallback, and useMemo.

TypeScript + React in Practice #2: Typing props and children
3 min read

TypeScript + React in Practice #2: Typing props and children

How to define props types and how far to narrow them — optional props, union props, and children patterns. Real-world decisions you meet often.