Command Palette

Search for a command to run...

Hectal
Phase 9: Conditional and Template Literal Types
TypeScript · Exercise 5 of 5 Previous
Advanced

Links That Demand the Right Parameters

A route like "/users/:id/posts/:postId" has parameters id and postId. Finish RouteParams<P> so it is the union of those names, then type link so its second argument must have exactly those keys.

Fill in link too: it replaces each :name in the path with the value. The program prints the finished link.

What Check tests

  1. Your code has no type errors
  2. The link is printed
  3. A missing parameter is rejected
  4. An unknown parameter is rejected
  5. A correct call is accepted

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.