Command Palette

Search for a command to run...

Hectal
Phase 4: Unions, Literals and Narrowing
TypeScript · Exercise 4 of 6 PreviousNext
Intermediate

Never Forget a Case

A new shape, the triangle, was added to Shape, but area doesn't handle it, and assertNever complains. Read the error: it names the missing type.

Add the missing case returning (base * height) / 2. Keep the assertNever call in the default branch.

What Check tests

  1. Your code has no type errors
  2. The console prints 16 and 6
  3. assertNever is still used
  4. An unknown kind 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.