Advanced
Type the parameters of a route string
Write Params<S extends string> that turns a route like "/users/:id/posts/:postId" into the union "id" | "postId". A route with no : parts gives never.
Then complete url(path, params) so params must have exactly those keys (use Record<Params<S>, string>). It replaces each :name in the path with the value and returns the result.
What Check tests
- Your code has no type errors
- The URL is built
- A correct call is accepted
- A wrong key is rejected
- A missing key 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.
Press Run to see the page.
Console
Nothing printed yet.