Course contentsShow
← TypeScript
Lesson 666 of 1,79616. Utility TypesFree lesson

Partial with Nested Objects

Understanding that Partial is shallow—nested objects remain required unless explicitly wrapped in Partial again.

Partial with Nested Objects

What you'll learn: How Partial<T> only makes the top-level properties optional, leaving nested objects fully required.


When you apply Partial<T> to an object type, TypeScript makes all of the immediate properties optional — but it doesn't dive deeper. Nested objects remain untouched, with all their properties still required.

The Shallow Nature of Partial

Think of Partial like applying a layer of paint: it only covers the surface. The internal structure stays exactly as it was.

type Address = {
  street: string;
  city: string;
  zipCode: string;
};

type User = {
  name: string;
  email: string;
  address: Address;
};

type PartialUser = Partial<User>;
// Result:
// {
//   name?: string;
//   email?: string;
//   address?: Address; // ← optional itself, BUT...
// }

Notice that address is now optional — you can omit it entirely. But if you do provide an address, it must still have all its properties:

const updateUser: PartialUser = {
  name: "Alice",
  address: {
    street: "123 Main St",
    city: "Boston",
    // ERROR: zipCode is missing!
  }
};

Making Nested Objects Partial Too

If you want nested properties to also be optional, you must explicitly wrap them:

type DeepPartialUser = {
  name?: string;
  email?: string;
  address?: Partial<Address>; // ← now street, city, zipCode are optional
};

Now address.city can be provided without street or zipCode.

Key Takeaway: Partial<T> is shallow — it only affects the first level of properties. Nested objects remain fully required unless you explicitly apply Partial to them as well.