elysiajs/elysia

Elysia type inference breaks on monorepos

Closed this issue · 1 comments

What version of Elysia is running?

1.1.22

What platform is your computer?

WSL2 on Windows (Microsoft Windows NT 10.0.19045.0 x64)

What steps can reproduce the bug?

I think the easiest way is to clone the example monore:
https://github.com/SaltyAom/elysia-monorepo-example

  1. Create a bun monorepo
  2. Do any type of validation using elysia
  3. If it's on elysia 1.0.*
    You get unknown as the type inference for body, params, query, etc...
    If it's on elysia 1.1.*
    You get any as the type inference for body, params, query, etc...

What is the expected behavior?

Elysia should infer the types correctly after the validation

What do you see instead?

Everything is typed as any or unknown depending on which version of elysia you are running.

Additional information

Things tried to debug it:

  1. rm -rf node_modules && bun.lockb
  2. downgrading elysia until
  3. Adding bun types globally using tsconfig.json and installing it to the package.json.
  4. Installing @sinclair/typebox directly and trying to use it for validation. The result is the same behavior as when using elysia version 1.0.27 and under. (unknown infered for body, params, etc)

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

Yes

Sorry, this is not a real bug, I messed up my tsconfig.json.

// Changing
"strictNullChecks": false to true
// solved the issue for me.