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

mapResponse types are not aligned with runtime behavior #987

Open
mattersj opened this issue Jan 2, 2025 · 0 comments
Open

mapResponse types are not aligned with runtime behavior #987

mattersj opened this issue Jan 2, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@mattersj
Copy link

mattersj commented Jan 2, 2025

What version of Elysia is running?

1.2.9

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

Since 1.2.7 response type in mapResponse was changed to unknown and now is not aligned with the way runtime works.

new Elysia().mapResponse(({ response }) => response); works perfectly in runtime but gives an error on a type level (see test/lifecycle/map-response.test.ts:266). Apparently, it now forces you to handle unknown type and convert it manually to Response which is not really convenient and requires you to do stuff like JSON.stringify on your own.

I think the runtime behavior makes more sense and it should be allowed to return any type (taking into account the response schema if provided) as you already can do in the handler itself (you can still choose to return Response explicitly if you want to though).

What is the expected behavior?

mapResponse return type should be aligned with runtime behavior.

What do you see instead?

image

Additional information

No response

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

No response

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