HomeGuidesTypeScriptTypeScript Utility Types — Partial, Required, Pick, Omit, Record
🔷 TypeScript

TypeScript Utility Types: Partial, Pick, Omit, Record

Utility types transform existing types into new ones. These save you from writing repetitive type definitions.

Examifyr·2026·5 min read

Partial, Required, and Readonly

These three transform all properties in a type at once.

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

// All properties become optional
type PartialUser = Partial<User>;
// { id?: string; name?: string; email?: string; }

// All properties become required
type RequiredUser = Required<PartialUser>;
// { id: string; name: string; email: string; }

// All properties become readonly
type ReadonlyUser = Readonly<User>;
// { readonly id: string; readonly name: string; ... }

// Common pattern: update function accepts partial updates
function updateUser(id: string, updates: Partial<User>) {
    return fetch(`/users/${id}`, {
        method: 'PATCH',
        body: JSON.stringify(updates),
    });
}

Pick and Omit

Pick creates a type with only the specified properties. Omit creates a type without them.

interface User {
    id: string;
    name: string;
    email: string;
    password: string;
    createdAt: Date;
}

// Include only specific properties
type PublicUser = Pick<User, "id" | "name" | "email">;
// { id: string; name: string; email: string; }

// Exclude specific properties
type UserWithoutPassword = Omit<User, "password">;
// { id: string; name: string; email: string; createdAt: Date; }

// Common pattern: API response type
type UserResponse = Omit<User, "password">;

Record

Record creates an object type with specific key and value types.

// Record<Keys, Values>
type ScoreMap = Record<string, number>;
const scores: ScoreMap = { alice: 95, bob: 87 };

// With literal key union
type Role = "admin" | "user" | "guest";
type Permissions = Record<Role, string[]>;

const perms: Permissions = {
    admin: ["read", "write", "delete"],
    user:  ["read", "write"],
    guest: ["read"],
};

// Useful pattern: index signature alternative
type CacheEntry = { value: string; expires: number };
type Cache = Record<string, CacheEntry>;

Exclude, Extract, NonNullable, ReturnType

These utility types operate on union types and functions.

type A = Exclude<string | number | boolean, boolean>;
// string | number

type B = Extract<string | number | boolean, string | boolean>;
// string | boolean

type C = NonNullable<string | null | undefined>;
// string

function fetchData() { return { id: 1, name: "Alice" }; }
type D = ReturnType<typeof fetchData>;
// { id: number; name: string }

// Parameters extracts argument types
function login(email: string, password: string) {}
type E = Parameters<typeof login>;
// [email: string, password: string]

Exam tip

Partial<T> is the most commonly used utility type in real code — it's used everywhere for update/patch functions. Know all five: Partial, Required, Readonly, Pick, and Omit. They're all tested.

🎯

Think you're ready? Prove it.

Take the free TypeScript readiness test. Get a score, topic breakdown, and your exact weak areas.

Take the free TypeScript test →

Free · No sign-up · Instant results

← Previous
TypeScript Generics Explained — Generic Functions, Constraints & keyof
Next →
TypeScript Type Narrowing — typeof, instanceof, Custom Type Guards
← All TypeScript guides