Type Transformations Workshop (6 exercises)
Problem

Only Allow Specified String Patterns

Here we have a function called goToRoute, where Route is currently unknown:

We want to make it so that only certain types of strings can be passed into goToRoute:

Challenge

Your challenge is to change Route into something that allows any string that starts with a forward slash.

Here are some examples of strings that should succeed:

These examples should give an error:

Hint: To solve this challenge, check out Template Literal Types in the TypeScript Docs.