Command Palette

Search for a command to run...

Hectal
Phase 1: Basic Types and Annotations
TypeScript · Exercise 4 of 6 PreviousNext
Beginner

Describe the Shape of a User

describe receives an object, but its parameter has no type. Give user an object type: a required name (text), a required age (number) and an optional email (text).

The checks pass valid and invalid objects to describe.

What Check tests

  1. Your code has no type errors
  2. The console prints Asha (30) no email
  3. An object with an email is accepted
  4. A user without an age is rejected
  5. An unknown property 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.

Console

Nothing printed yet.