Partial Utility Type
What
The Partial<T> utility type takes an existing type and creates a new one where every top-level property is optional.
How
You wrap the target type in Partial:
type User = {
id: string;
name: string;
email: string;
};
// All properties are now optional
function updateUser(id: string, updates: Partial<User>) {
// ...
}
Why
Partial is extremely useful for update operations. When a user updates their profile, they usually only change one or two fields. Partial allows you to accept an object containing any subset of the user’s properties without needing to manually define a “UserUpdate” interface.
Summary
Use Partial<T> when you need a flexible version of a type where any or all properties can be missing.