Enforce immutability on object properties

Flow
Easy

Objective

Make the name & id properties immutable using Flow type annotations

Requirements

  1. Modify the User type to make the id and username properties immutable.

  2. Make sure that calling updateUser function with modified User type will not throw Flow errors.

Starting code

// @flow type User = { id: number, username: string, email: string, }; function updateUser(user: User, newEmail: string) { user.email = newEmail; } const user: User = { id: 1, username: 'JohnSmith', email: 'john.smith@example.com', }; updateUser(user, 'john.new@example.com');