Mahamudul Hasan Rubel
HomeAboutProjectsSkillsExperienceBlogPhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • About
  • Projects
  • Skills
  • Experience
  • Blog
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
TypeScriptJavaScriptJune 20, 20264 min read

TypeScript utility types you will reach for weekly

TypeScript utility types can save you hours of boilerplate code. Learn the essential tools I use weekly to keep my production projects clean and type-safe.

TypeScriptJavaScriptProgrammingSoftware EngineeringDevelopmentFrontend
Typewritten note with 'I love you' on vintage paper background, evoking nostalgia.

I remember staring at a 400-line types.ts file, manually copying interface properties just to create a "partial" version for an API update. It was the kind of repetitive, soul-crushing work that makes you question your career choices. That was before I fully leaned into the built-in TypeScript utility types.

These utilities aren't just academic exercises; they are the bread and butter of keeping your codebase maintainable. When you’re dealing with React 19 upgrades, for example, having a robust type system helps you map props and state changes without losing your mind.

Why TypeScript utility types matter for your workflow

The core value of utility types is simple: they allow you to derive new types from existing ones. Instead of defining a User interface and then a PartialUser interface, you define User once and derive the rest. This drastically reduces the surface area for bugs when you add or rename a field.

In my experience, you’ll reach for these four almost every single day.

1. Partial<T>

This is the one I use the most. When you’re writing a patch request or an update function, you rarely need every field. Partial<T> makes every property of an object optional.

TYPESCRIPT
interface User {
  id: string;
  email: string;
  role: CE9178">'admin' | CE9178">'user';
}

function updateUser(id: string, updates: Partial<User>) {
  // Now you can pass just { email: CE9178">'new@example.com' }
}

2. Pick<T, K> and Omit<T, K>

These are your best friends when you need to transform data structures. Pick lets you create a type with only a specific subset of keys, while Omit does the inverse.

I once spent about two days trying to manually reconcile types for a complex form component. Switching to Pick allowed me to define a specific FormFields type directly from my DatabaseModel, ensuring that if the database schema changed, my form type followed suit automatically.

3. Record<K, T>

If you’re building a lookup table or a map, Record is the standard. It’s cleaner than writing {[key: string]: number}.

TYPESCRIPT
type StatusMap = Record<string, boolean>;
const activeUsers: StatusMap = {
  CE9178">'rubel': true,
  CE9178">'guest': false
};

When utility types help (and when they hurt)

Don’t get me wrong—it’s easy to over-engineer. I once tried to build a deeply nested type using Exclude and Extract that became so complex that the TypeScript compiler took roughly 280ms longer to check that single file. That might sound like nothing, but in a large project, those milliseconds add up to a sluggish DX.

If you find yourself chaining more than three utility types together, stop. It’s usually a sign that your underlying data model needs a rethink, or you’re trying to force a generic solution where a concrete interface would be more readable.

The power of conditional types

Red building exterior with multiple windows and air conditioners, showcasing urban architecture.

If you want to move beyond the basics, look into conditional types. They allow you to create types that act like if statements.

TYPESCRIPT
type IsString<T> = T extends string ? "yes" : "no";

type A = IsString<string>; // "yes"
type B = IsString<number>; // "no"

While I don't use these every day, they are essential for library authors or when building highly reusable UI components. If you're currently optimizing your React performance patterns, you'll often find that conditional types allow you to create safer, more flexible component APIs that don't need excessive any casting.

Frequently Asked Questions

Is it better to use utility types or interfaces?

Use interfaces for your base models and utility types to derive variations of those models. Don't pick one over the other; use them together to keep your code DRY.

Do these types affect runtime performance?

Not at all. Since TypeScript is a compile-time tool, these utilities vanish once your code is transpiled to JavaScript. They exist only to help you catch errors before you ship.

Should I use these in a legacy codebase?

Absolutely. Even if you're slowly migrating a project, using Partial or Pick on your existing interfaces can help you catch bugs in your migration logic without requiring a massive refactor of your core types.

Wrapping up

Hands wrapping an item in brown paper with sunlight streaming in, highlighting the texture and details.

The beauty of these utilities is that they force you to think about the relationship between your data structures. When you stop writing code that repeats itself, you start writing code that explains itself.

I’m still not convinced that complex recursive types are worth the maintenance burden in most business apps. I’d rather have a slightly verbose interface that a junior dev can understand in five seconds than a "clever" utility chain that requires a PhD to debug. Start with Partial and Pick, see how they fit your workflow, and ignore the rest until you actually have a problem they solve.

Back to Blog

Similar Posts

Detailed view of code and file structure in a software development environment.
TypeScriptJavaScriptJune 20, 20264 min read

TypeScript narrowing: How to make the compiler trust your code

TypeScript narrowing is the key to writing type-safe code without constant casting. Learn how to guide the compiler through your logic for cleaner builds.

Read more
A vibrant workspace showing computer monitors with code, keyboard, and tech accessories.
TypeScriptJavaScriptJune 20, 20264 min read

Generics in TypeScript that actually pay off for your codebase

Generics in TypeScript can feel like an academic hurdle, but they pay off when you use them to enforce type safety in API calls and reusable components.

Read more
Detailed view of programming code in a dark theme on a computer screen.
TypeScriptJavaScriptJune 20, 20264 min read

Typing async code in TypeScript without fighting the compiler

Typing async code in TypeScript doesn't have to be a battle. Learn how to handle promises, API responses, and error states without fighting the compiler.

Read more