Advanced types

This part builds types from other types: discriminated unions, intersections, mapped and conditional types, infer, template literal types, keyof and typeof, the built-in utility types, and the satisfies and as const forms that keep a literal type.

31 Discriminated unions one-of-many shapes with a shared literal tag, narrowed with a switch Open 32 Intersections combine object types with & and mix shared behaviour into a value Open 33 Mapped types build a new object type by mapping over the keys of an old one Open 34 Conditional types choose between two types with a condition that distributes over a union Open 35 infer capture a hidden type inside a conditional with infer Open 36 Template literal types string types built from a pattern, and the checks they make possible Open 37 keyof and typeof derive a key union with keyof and a type from a value with typeof Open 38 Utility types Partial, Pick, Omit and the other built-in types that reshape an object Open 39 satisfies check a shape without widening the literals inside it Open 40 const assertions as const freezes a value into its literal type, and what that buys Open

Lessons