When to Use Built-In Utilities vs Custom Mapped Types
You'll learn: How to decide when a built-in utility type is sufficient versus when you need to create your own mapped type.
The Decision Framework
Think of built-in utility types like buying tools at a hardware store—they're ready-made and solve common problems. Custom mapped types are like building your own specialized tools—more effort, but perfectly fitted to unusual needs.
Use Built-In Utilities When:
The transformation is standard. If you need all properties optional (Partial<T>), all readonly (Readonly<T>), or a subset of properties (Pick<T, K>), the built-in utilities are clearer and more recognizable to other developers.
Readability matters. Code like Partial<User> immediately communicates intent. A custom mapped type requires readers to parse the transformation logic.
You're working with common patterns. Removing null/undefined (NonNullable<T>), extracting return types (ReturnType<F>), or creating lookup objects (Record<K, T>) are solved problems—don't reinvent them.
Create Custom Mapped Types When:
The transformation is unique to your domain. Need all properties to become arrays? All string properties to become uppercase? Built-ins won't help.
You need conditional logic per property. If certain properties transform differently based on their type, you'll need a custom mapped type with conditional types.
You're building reusable infrastructure. When you find yourself applying the same complex transformation repeatedly, extract it into a named custom mapped type for your codebase.
The Clarity Principle
Even when you could create a custom mapped type, prefer built-ins if they exist. Required<Config> beats { [K in keyof Config]-?: Config[K] } every time—not because it's shorter, but because it's immediately understood.
Key Takeaway: Choose built-in utilities for standard transformations and team clarity; create custom mapped types only when you need domain-specific or complex property transformations that built-ins can't express.