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

Invalid onAfterResponse typing #838

Closed
nxht opened this issue Sep 20, 2024 · 6 comments
Closed

Invalid onAfterResponse typing #838

nxht opened this issue Sep 20, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@nxht
Copy link

nxht commented Sep 20, 2024

What version of Elysia is running?

1.1.13

What platform is your computer?

Linux 5.15.153.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

import Elysia from 'elysia';

const app = new Elysia()
  .onAfterResponse((ctx) => {
    ctx.request;
  })

What is the expected behavior?

ctx is typed correctly and ctx.request exists

What do you see instead?

ctx is inferred as never in typescript

Additional information

Same issue doesn't happen on 1.1.12. Might be related with #810

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

Yes

@nxht nxht added the bug Something isn't working label Sep 20, 2024
@bompus
Copy link

bompus commented Sep 20, 2024

I commented on a commit actually, but I don't think the author saw it. It appears the unit test for this was commented out, so the regression wasn't caught.

// expectTypeOf<typeof params>().toEqualTypeOf<Record<string, string>>()

@7f8ddd
Copy link

7f8ddd commented Sep 23, 2024

It's also only in the plugin itself, any plugins that use it will have types.

@nathankleyn
Copy link
Contributor

nathankleyn commented Sep 23, 2024

We also have this exact same issue from 1.1.13 onwards. In our case, it's a logging "middleware" where all of the params to .onAfterResponse now type as never:

return new Elysia({
  name: "logger",
})
  .derive(() => {
    return {
      startTime: performance.now(),
    };
  })
  .onAfterResponse({ as: "global" }, ({ request, set, startTime }) => {
    // request, set and startTime are all `never`
  });

@crishoj
Copy link
Contributor

crishoj commented Sep 23, 2024

Wrong types with 1.1.16 too:

image

@ghost
Copy link

ghost commented Sep 27, 2024

same here
image

@7f8ddd
Copy link

7f8ddd commented Sep 27, 2024

@SaltyAom We gonna have beef real soon if you don't stop watching anime girls and fix this, on folk n em

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

5 participants