RecipesChapter 4: Generics

Adding Const Context to Generic Type Parameters

Recipe 4.9 from The TypeScript Cookbook

const rtr = router([
  {
    path: "/",
    component: Main,
  },
  {
    path: "/about",
    component: About,
  },
])

rtr.navigate("/faq");
//             ^
// Argument of type '"/faq"' is not assignable to
// parameter of type '"/" | "/about"'.(2345)
Open in TypeScript Playground →