Command Palette

Search for a command to run...

Hectal
Phase 3: Type Aliases and Interfaces
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

  1. Your code has no type errors
  2. The console prints { x: 0, y: -1 }
  3. move accepts "left"
  4. move rejects the direction "north"
  5. A point without y 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.