Skip to content
You must be logged in to vote

@1EDExg0ffyXfTEqdIUAYNZGnCeajIxMWd2vaQeP #27 is not the same issue. But #3 is, yeah.
This can be easily solved using idiomatic TypeScript:

const routes = {
  Root: "/",
  Index: "/contacts",
  Contact: "/contacts/:id",
  EditContact: "/contacts/:id/edit",
  DestroyContact: "/contacts/:id/destroy",
} as const; // declare routes as const

type Routes = typeof routes;
type RouteName = keyof Routes;

export const router = createRouter(routes);

// the cast is necessary since Object.keys typing is not that good
// https://swan-io.github.io/boxed/dict doesn't have this issue
export const routeNames = Object.keys(routes) as RouteName[];

// You can also consider:
export const useAllRoutes = () => 

Replies: 3 comments

You must be logged in to vote
0 replies
You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by zoontek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants