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

InferContext not inferring types of query and body #935

Open
mithleshjs opened this issue Dec 6, 2024 · 0 comments
Open

InferContext not inferring types of query and body #935

mithleshjs opened this issue Dec 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mithleshjs
Copy link

What version of Elysia is running?

1.1.26

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

I am using a separate file for handlers and using InferContext for type safety

export const TrackingModule = new Elysia()
  .use(services)
  .get("/", handleTrackingRedirect, { query: TrackingQuerySchema })
  .post("/callback", handleCallback, { body: CallbackBodySchema });
export async function handleTrackingRedirect({
  db,
  request,
  redirect,
  error,
  query: { campaign_id, inventory_id, url },
}: InferContext<typeof TrackingModule>) {}

export async function handleCallback({
  db,
  error,
  body: { clk_id, txn_id },
}: InferContext<typeof TrackingModule>) {}

What is the expected behavior?

It should infer the type of query and body but it is not doing so.

What do you see instead?

I am getting the type error for body in handler.

Additional information

No

Have you try removing the node_modules and bun.lockb and try again yet?

Yes

@mithleshjs mithleshjs added the bug Something isn't working label Dec 6, 2024
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

No branches or pull requests

1 participant