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
- Your code has no type errors
- The link is printed
- A missing parameter is rejected
- An unknown parameter is rejected
- 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.
Press Run to see the page.
Console
Nothing printed yet.