Makes all properties of a type optional.
type PartialType = Partial<OriginalType>;
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*
?).