14.7 Building Custom Utility Types with Mapped Types
Right, so you’ve grasped the basics of mapped types—iterating over keys, slapping on a modifier or two. But that’s like learning how to hold a scalpel. The real fun begins when you start building your own utility types, the ones that solve your specific problems. This is where you move from reading the map to drawing your own. Let’s start by building something deceptively simple but incredibly powerful. You know how Partial<T> makes everything optional? What if you need the exact opposite? A type where every property is required, even the ones that were originally optional? The existing Required<T> type does this, but let’s build our own to see the gears turn.