Skip to content

Splitting up the route function #26

Answered by sandulat
moishinetzer asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @moishinetzer, sorry for late response! For some reason, Github doesn't notify me about new discussions.

Considering the following generated routes example:

declare module "routes-gen" {
  export type RouteParams = {
    "/admin/:userId": { userId: string };
    "/admin/:userId/invoices": { userId: string };
    "/admin/:userId/invoices/:invoiceId": { userId: string; invoiceId: string };
  };
  
  export function route<
    T extends
      | ["/admin/:userId", RouteParams["/admin/:userId"]]
      | ["/admin/:userId/invoices", RouteParams["/admin/:userId/invoices"]]
      | ["/admin/:userId/invoices/:invoiceId", RouteParams["/admin/:userId/invoices/:invoiceId"]]
  >(...args: T): typeof a…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by moishinetzer
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