elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
10.59k stars 226 forks source link

Different `params` return type from global instance context to `beforeHandle` handler context #850

Open caturbgs opened 1 month ago

caturbgs commented 1 month ago

What version of Elysia is running?

Elysia v1.1.16

What platform is your computer?

Darwin 24.0.0 arm64 arm

What steps can reproduce the bug?

  1. global elysia instance
  1. beforeHandle handler
    • create plugin using functional callback, and infer the params using the global instance type
      const newPluginTest = (app: AppTest) => {
      };
    • define the beforeHandle hook
      const newPluginTest = (app: AppTest) => {
      app.guard({
      beforeHandle(context) {},
      });
      };
    • hover to params of beforeHandle hook to check the types of context image

What is the expected behavior?

As you can see, the type of context.params is different each others, I think it should be the same as the local plugin it's used in the global instance.

What do you see instead?

the type of context.params on global instance is never, but the type of context.params on plugin instance is {}.

Additional information

No response

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

i've done it, but the issue persist