elysiajs / eden

Fully type-safe Elysia client
MIT License
174 stars 41 forks source link

baseUrl causes the typescript compiler to lose track of types and replace the edenTreaty client with any #42

Closed m1212e closed 10 months ago

m1212e commented 10 months ago

Hi,

I just wanted to raise awareness about this since it took a lot of time for me to figure this out, maybe this will help someone save some time in the future:

I use eden and elysia to provide a typesafe way to access my api. Since I'm writing an API which is intended to be used across many projects, I decided to provide a library/sdk to access it. This library provides some init code and exports an edenTreaty api client to access the actual api. After building my library the output .d.ts files did not contain the correct types. TS replaced the return type of the edenTreaty call with an "any" type. It took me a very long time to figure out, why this was happening:

I used the "baseUrl" property in my tsconfig.json (the one in the API package, not the client) to simplify imports. After replacing that with relative imports, everything works as expected. I'm not really expecting the eden/elysia project to do something about this, so I'll instantly close this, but I wanted to create some record so people don't have to deal with the same issue as long as I did.

Ripwords commented 4 months ago

https://github.com/elysiajs/eden/issues/110#issuecomment-2211609516

I had the same issue but was due to alias, you can try this fix to see if it helps you