Partial<T>
Constructs a type with all properties of T set to optional.
Syntax
Partial<Type> Returns
object type — A new type identical to T but with every property marked optional.
Examples
interface User {
id: number;
name: string;
}
function update(user: User, fields: Partial<User>): User {
return { ...user, ...fields };
}
update({ id: 1, name: 'Ada' }, { name: 'Grace' });
type Config = { host: string; port: number };
const defaults: Partial<Config> = { host: 'localhost' };
Notes
Implemented as a homomorphic mapped type that adds the `?` modifier to every
property. It is shallow: nested object properties are not made optional. Use it
for patch/update payloads where any subset of fields may be supplied.