What it Does

Makes all properties of a type optional.

Syntax

type PartialType = Partial<OriginalType>;

Use Cases

Detailed Example

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

*// Update function accepting partial user data*
function updateUser(id: number, updates: Partial<User>) {
  *// Only fields provided in 'updates' will be changed*
  return { ...existingUser, ...updates };
}

*// Valid calls - any combination works*
updateUser(1, { name: "Alice" });
updateUser(1, { email: "alice@example.com", age: 25 });
updateUser(1, {}); *// Even empty object is valid*

Key Points

image.png