0Pricing
TypeScript Academy · Lesson

Partial, Readonly, Record, Pick, Omit

Master key utility types to reshape objects: Partial, Readonly, Record, Pick, and Omit.

Partial, Readonly, Record, Pick, Omit is a free TypeScript Academy lesson on CoddyKit — lesson 2 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the TypeScript Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Intro

Goal: Reshape object types safely with Partial, Readonly, Record, Pick, and Omit. These tools remove boilerplate and prevent bugs.

Partial

Partial<T> makes all properties optional—perfect for update payloads.

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

type UserUpdate = Partial<User>;
const patch: UserUpdate = { name: "Ada" }; // only changed fields

Readonly

Readonly<T> prevents reassignment of properties—great for shared configuration.

type Config = Readonly<{ api: string; timeout: number }>;
const cfg: Config = { api: "https://api", timeout: 1000 };
// cfg.timeout = 2000; // Error: readonly

Record

Record<K,T> builds a type with keys from union K and uniform values of type T.

type Status = "idle" | "loading" | "error";
type Flags = Record<Status, boolean>;
const f: Flags = { idle: true, loading: false, error: false };

// Also works for arbitrary string keys
const scores: Record<string, number> = { math: 95, eng: 88 };

Pick & Omit

Pick selects certain properties; Omit removes some. Ideal for view models and API DTOs.

interface User {
  id: number;
  name: string;
  email?: string;
  role: "user" | "admin";
}

type PublicUser = Pick<User, "id" | "name">;
type PrivateUser = Omit<User, "role">;

const pu: PublicUser = { id: 1, name: "Ada" };
const pr: PrivateUser = { id: 1, name: "Ada", email: "a@x.io" };

Tips

Tips:

  • Combine utilities: Readonly<Partial<T>> for immutable patches.
  • Use Record for key → value maps.
  • Prefer Pick/Omit over re-declaring similar types.

Record utility check

Quick check: Which utility maps a set of keys to a single value type?

Recap

Recap: Partial for patches, Readonly for immutability, Record for key→value maps, Pick/Omit to reshape models quickly.

Frequently asked questions

Is the “Partial, Readonly, Record, Pick, Omit” lesson free?

Yes — the full text of “Partial, Readonly, Record, Pick, Omit” is free to read here on the web, and the TypeScript Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the TypeScript Academy course, upgrade to CoddyKit PRO.

What will I learn in “Partial, Readonly, Record, Pick, Omit”?

Master key utility types to reshape objects: Partial, Readonly, Record, Pick, and Omit. You practise TypeScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start TypeScript Academy?

No prior experience is required. TypeScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 3, so you can start here or from the beginning and move at your own pace.

How long does the “Partial, Readonly, Record, Pick, Omit” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this TypeScript Academy lesson?

Yes. Every TypeScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Generic functions & constraints (extends, default params)
  2. Partial, Readonly, Record, Pick, Omit
  3. keyof/indexed access types (intro)
← Back to TypeScript Academy