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

When setting a response in the options, type of request becomes 'any' #990

Open
NickBlow opened this issue Jan 3, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@NickBlow
Copy link

NickBlow commented Jan 3, 2025

What version of Elysia is running?

1.2.9

What platform is your computer?

Darwin 24.2.0 arm64 arm

What steps can reproduce the bug?

import { Elysia, error, redirect, StatusMap, t } from "elysia";
import { swagger } from "@elysiajs/swagger";

const SYSTEM_UPLOAD_ROUTE = "/system/files";

export const uploadResponse = t.Object({
  id: t.String(),
});

export const router = new Elysia({ aot: false })
  .use(swagger())
  .post(
    SYSTEM_UPLOAD_ROUTE,
    async ({ request, query }) => {
      return {
        id: crypto.randomUUID(),
      };
    },
    {
      response:{
        200: uploadResponse
      }
    }
  );

When the 'response' is present, the type of request is `any. If you remove it, then the type is now correctly Response. See attached screenshots.

Screenshot 2025-01-03 at 23 43 05 Screenshot 2025-01-03 at 23 43 25

What is the expected behavior?

Correct type inference of the request etc.

What do you see instead?

The request is typed as any

Additional information

No response

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

yes

@NickBlow NickBlow added the bug Something isn't working label Jan 3, 2025
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