HomeChallengesRepsProblemsLeaderboardTake a challenge

State that knows its shape

useState([]) infers never[], so nothing can ever be added to the queue, and useState(null) can only ever hold null. The total is stored separately and drifts. Type the state, and derive the total.

Beginner8 min on the clock5 graded checks · 100 pointsTyped React
Graded by running your code against real cases.

What you build

  • useState<Order[]>(initial) for the queue
  • useState<Order | null>(null) for the selection
  • Compute total from the queue instead of storing it
  • Leave no any and no casts

Done means

The queue is Order[], the selection is Order | null, the total is derived, and the screen shows the real queue.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. The queue is Order[], not never[]+20React state
  2. The selection is Order | null+25React state
  3. The total is derived, not stored+20React state
  4. The screen shows the real queue+20React state
  5. No any, no casts, and it compiles+15TypeScript basics

What it teaches

The rest of Typed React