cf.completefrontend

Write the codeMedium

Type updateUser(user, changes) so changes can hold any editable field, but never id or createdAt.

changes holds only the fields being changed, so every field is optional, and id and createdAt can't be changed at all. When User gets a new field, it should be editable without touching this code.

Write this
type User = {  id: string;  name: string;  email: string;  createdAt: Date;}; type UserChanges = User; // fix this type function updateUser(user: User, changes: UserChanges): User {  return { ...user, ...changes };} // updateUser(user, { name: "Grace" }); // OK// updateUser(user, { id: "2" });       // should be a type error

Solve it in the editor

The answer

Write it yourself first. Then compare it with a reference solution and the checks it passes.

Checking your sign-in…