TypeScript · Exercise 1 of 6Next
Beginner
Name the Shapes
The function move uses two types that don't exist yet, so the Types panel is full of Cannot find name errors.
Write a type alias Point (numbers x and y) and a type alias Direction that allows only "up", "down", "left" and "right". The checks call move with a wrong direction and expect TypeScript to refuse.
What Check tests
- Your code has no type errors
- The console prints
{ x: 0, y: -1 } moveaccepts"left"moverejects the direction"north"- A point without
yis 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.