Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create nested contract router with loosing path narrowing #47

Closed
oliverbutler opened this issue Sep 7, 2022 · 1 comment · Fixed by #138
Closed

Unable to create nested contract router with loosing path narrowing #47

oliverbutler opened this issue Sep 7, 2022 · 1 comment · Fixed by #138
Assignees
Labels
bug Something isn't working

Comments

@oliverbutler
Copy link
Collaborator

this works

const claims = c.router({
  getClaimsForApproval: {
    method: 'GET',
    path: `/partner/:partnerId/claims`,
    responses: { 200: c.response<{ id: string }[]>() },
    query: z.object({
      take: z.number().optional(),
      skip: z.number().optional(),
    }),
  }
});

export const claimServicePartnerApi = c.router({
  claims,
});

this doesn't work "path" becomes string

export const claimServicePartnerApi = c.router({
  claim: {
    getClaimsForApproval: {
      method: 'GET',
      path: `/partner/:partnerId/claims`,
      responses: { 200: c.response<{ id: string }[]>() },
      query: z.object({
        take: z.number().optional(),
        skip: z.number().optional(),
      }),
    }
 }
});

I think it's due to how I'm naïvely applying the Narrow helper, it probably should recursively go though the object...

@oliverbutler oliverbutler added the bug Something isn't working label Sep 7, 2022
@oliverbutler oliverbutler self-assigned this Sep 7, 2022
@oliverbutler
Copy link
Collaborator Author

Maybe going to migrate to TS's 4.9 Satisfies for the 4.0 launch 🤔 Should resolve this, I want to avoid super heavy recursive TS generics as much as possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant