DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
  1. Home
  2. Articles
  3. Frontend Engineering
  4. TypeScript Utility Types: Practical Applications
XLinkedInReddit
MediumFrontend Engineering

TypeScript Utility Types: Practical Applications

D
DevPrep Team
February 10, 2026·2 min read·0
Table of Contents
  • Essential Utility Types
  • Partial<T> — Make All Properties Optional
  • Required<T> — Make All Properties Required
  • Pick<T, K> and Omit<T, K>
  • Record<K, V> — Dictionary Type
  • Extract and Exclude
  • ReturnType<T> and Parameters<T>
  • Advanced Patterns
  • DeepPartial
  • Readonly with DeepReadonly
  • NonNullable<T>
  • Real-World Pattern: API Types

TypeScript's built-in utility types eliminate boilerplate and make your types more expressive. Here are the ones you'll use daily.

Essential Utility Types

Partial<T> — Make All Properties Optional

interface User {
  id: string;
  name: string;
  email: string;
  avatar: string;
}

// For update operations — all fields optional
function updateUser(id: string, updates: Partial<User>) {
  return db.update("users", id, updates);
}
updateUser("123", { name: "New Name" }); // OK, only name

Required<T> — Make All Properties Required

interface Config {
  host?: string;
  port?: number;
  ssl?: boolean;
}

// After merging with defaults, all properties exist
const config: Required<Config> = {
  host: "localhost",
  port: 3000,
  ssl: false
};

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

// API response: only public fields
type PublicUser = Pick<User, "id" | "name" | "avatar">;

// Form data: everything except id
type UserForm = Omit<User, "id">;

Record<K, V> — Dictionary Type

type StatusMap = Record<"pending" | "active" | "disabled", User[]>;

const usersByStatus: StatusMap = {
  pending: [],
  active: [user1, user2],
  disabled: [user3]
};

Extract and Exclude

type Event = "click" | "scroll" | "keydown" | "keyup";

type KeyEvent = Extract<Event, "keydown" | "keyup">; // "keydown" | "keyup"
type NonKeyEvent = Exclude<Event, "keydown" | "keyup">; // "click" | "scroll"

ReturnType<T> and Parameters<T>

function createUser(name: string, age: number) {
  return { id: crypto.randomUUID(), name, age };
}

type NewUser = ReturnType<typeof createUser>; // { id: string; name: string; age: number }
type CreateUserArgs = Parameters<typeof createUser>; // [string, number]

Advanced Patterns

DeepPartial

type DeepPartial<T> = {
  [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
};

Readonly with DeepReadonly

type DeepReadonly<T> = {
  readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];
};

NonNullable<T>

type MaybeString = string | null | undefined;
type DefiniteString = NonNullable<MaybeString>; // string

Real-World Pattern: API Types

interface Article {
  id: string;
  title: string;
  content: string;
  author: User;
  createdAt: Date;
}

type CreateArticleDTO = Omit<Article, "id" | "createdAt" | "author">;
type UpdateArticleDTO = Partial<CreateArticleDTO>;
type ArticlePreview = Pick<Article, "id" | "title"> & { authorName: string };

Related Articles

MediumFrontend Engineering

System Design #12: Design a Multi-Step Form Wizard

7 min read
MediumFrontend Engineering

Mastering Senior-Level JavaScript Interview Concepts

2 min read
MediumFrontend Engineering

System Design #9: Design a Collaborative Text Editor

9 min read

Comments (0)

Sign in to leave a comment.

No comments yet. Be the first to comment.

Table of Contents

  • Essential Utility Types
  • Partial&lt;T&gt; — Make All Properties Optional
  • Required&lt;T&gt; — Make All Properties Required
  • Pick&lt;T, K&gt; and Omit&lt;T, K&gt;
  • Record&lt;K, V&gt; — Dictionary Type
  • Extract and Exclude
  • ReturnType&lt;T&gt; and Parameters&lt;T&gt;
  • Advanced Patterns
  • DeepPartial
  • Readonly with DeepReadonly
  • NonNullable&lt;T&gt;
  • Real-World Pattern: API Types

Series

View all Frontend Engineering articles →

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.