Beginner
Describe a User
Fill in the interface User: a readonly number id, a text name, and an optional text nickname.
The code makes a user u and prints its nickname or a fallback. The checks try to change u.id and to create a user with no name, and expect TypeScript to refuse both.
What Check tests
- Your code has no type errors
- The console prints
Ashaandno nickname - Changing
u.idis rejected - A user with a nickname is accepted
- A user without a name is rejected
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.