Code QuizAdvanced

Partial for update functions

Using Partial<T> so an update function accepts a subset of properties.

Codetypescript
interface User {
  id: number;
  name: string;
}

function updateUser(user: User, changes: User): User {
  return { ...user, ...changes };
}

updateUser({ id: 1, name: "Ann" }, { name: "Bob" }); // Error: property 'id' is missing

What is the bug that causes the call to updateUser to fail?