Partial
Partial
makes all properties of a type optional, creating a type with the same properties but each marked as optional.- Useful when
updating
ormodifying
parts of an object.
interface User { id: string; name: string; age: number; email: string; password: string;}
type UpdateUserProps = Partial<Pick<User, 'name' | 'age' | 'email'>>;
function updateUser(updatedProps: UpdateUserProps) { // Update user in the database console.log('Updated user:', updatedProps);}
updateUser({ name: 'Jane Doe', age: 30 });