elysiajs / eden

Fully type-safe Elysia client
MIT License
147 stars 37 forks source link

Using typescript path aliases, eg. @app on the server break eden treaty typing. #110

Closed IOnlyNeedParenthesis closed 2 months ago

IOnlyNeedParenthesis commented 2 months ago

Hello, I have been developing on a monorepo with elysia. When using the eden treaty, route parameters are type hinted as any instead of the expected types. We have narrowed it down to being a path aliasing issue.

See this repository for a reproduction https://github.com/IOnlyNeedParenthesis/elysia-eden-treaty-repro. This seems to be the same issue as in #99 and possibly related to #42.

Ripwords commented 2 months ago

I'm not sure if it's necessarily an Elysia/Eden issue. The workaround is just to simply update your frontend's tsconfig.json to reference your backend tsconfig.json

Frontend

"references": [
    {
      "path": "../backend"             // Add reference to the backend tsconfig
    }
  ]

Backend

 "compilerOptions": {
    "composite": true,                 // Enable this line
}

Here's my working template if anyone needs to refer https://github.com/Ripwords/elysia-lucia-template

IOnlyNeedParenthesis commented 2 months ago

Hey @Ripwords, your solution solves the issue. Thanks a lot.