Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Part 6.2Mapped and conditional types

Mapped types

A mapped type iterates over keys in another type. It is powerful for library code and repeated application patterns, but a named interface is often clearer for one-off values.

TypeScript
type Flags<T> = {
  readonly [K in keyof T]: boolean;
};

Conditional types

A conditional type chooses a result based on a type relationship: T extends U ? X : Y. Learn to read these before building complex ones; clarity matters more than showing off the type system.

Feedback 👍
Comments are sent via email to me.