Single Source of Truth

Single Source of Truth
πŸ‘¨β€πŸ’Ό We want a single source of truth for route names and paths without enums. Using as const lets us derive types directly from the runtime object.
🐨 Open
index.ts
and:
  1. Add as const to the routes object
  2. Create RouteName and RoutePath types from the object
  3. Fix the defaultRoute assignment
  4. Implement getRoutePath to return the route path for a given name
πŸ’° keyof typeof gives you the keys; indexed access gives you the values.

Please set the playground first

Loading "Single Source of Truth"
Loading "Single Source of Truth"