elysiajs / eden

Fully type-safe Elysia client
MIT License
162 stars 40 forks source link

Eden Treaty: slow typescript intellisense #19

Open Fumaz opened 1 year ago

Fumaz commented 1 year ago

Hi, I'm using Elysia with Eden Treaty and I use multiple Elysia instances, some of them having prefixes to keep the code tidy. However, when trying to use Eden Treaty, the intellisense is really slow and most of the time it times out and just doesn't work at all.

SaltyAom commented 1 year ago

We are rewriting Elysia type which should essentially solve this problem. See https://github.com/elysiajs/elysia/pull/103

SaltyAom commented 1 year ago

Please leave this issue open until we get Elysia to 0.7

Fumaz commented 1 year ago

Having the same issue with elysia 0.7.0 and @elysiajs/eden 0.7.0

Fumaz commented 1 year ago

It actually gives me the following TypeScript error:

TS2344: Type 'Elysia<"", { request: { [x: string]: any; }; store: { [x: string]: any; }; }, { type: { [x: string]: any; }; error: { [x: string]: any; }; }, { body: unknown; headers: unknown; query: unknown; params: unknown; cookie: unknown; response: unknown; }, any, false>' does not satisfy the constraint 'Elysia<any, any, { type: {}; error: {}; }, {}, {}, false>'.
Types of property 'onError' are incompatible.
Type '<Schema extends RouteSchema = {}>(handler: ErrorHandler<{ [x: string]: any; }, MergeSchema<Schema, { body: unknown; headers: unknown; query: unknown; params: unknown; cookie: unknown; response: unknown; }>, { request: { [x: string]: any; }; store: { ...; }; }>) => Elysia<...>' is not assignable to type '<Schema extends RouteSchema = {}>(handler: ErrorHandler<{}, MergeSchema<Schema, {}>, any>) => Elysia<"", { request: { [x: string]: any; }; store: { [x: string]: any; }; }, { ...; }, { ...; }, any, false>'.
Types of parameters 'handler' and 'handler' are incompatible.
Types of parameters 'context' and 'context' are incompatible.
Type '{ [x: string]: any; body: unknown; query: Record<string, string | null>; params: never; headers: Record<string, string | null>; cookie: Record<string, Cookie<any>>; ... 5 more ...; error: Readonly<...>; } | ... 5 more ... | { ...; }' is not assignable to type '{ [x: string]: any; request: Request; code: "UNKNOWN"; error: Readonly<Error>; set: { headers: Record<string, string> & { 'Set-Cookie'?: string | string[] | undefined; }; status?: number | ... 60 more ... | undefined; redirect?: string | undefined; cookie?: Record<...> | undefined; }; } | ... 4 more ... | { ...; }'.
Type '{ [x: string]: any; body: unknown; query: Record<string, string | null>; params: never; headers: Record<string, string | null>; cookie: Record<string, Cookie<any>>; ... 5 more ...; error: Readonly<...>; }' is not assignable to type '{ [x: string]: any; request: Request; code: "UNKNOWN"; error: Readonly<Error>; set: { headers: Record<string, string> & { 'Set-Cookie'?: string | string[] | undefined; }; status?: number | ... 60 more ... | undefined; redirect?: string | undefined; cookie?: Record<...> | undefined; }; } | ... 4 more ... | { ...; }'.
Type '{ [x: string]: any; body: unknown; query: Record<string, string | null>; params: never; headers: Record<string, string | null>; cookie: Record<string, Cookie<any>>; ... 5 more ...; error: Readonly<...>; }' is not assignable to type '{ [x: string]: any; request: Request; code: "INVALID_COOKIE_SIGNATURE"; error: Readonly<InvalidCookieSignature>; set: { headers: Record<string, string> & { ...; }; status?: number | ... 60 more ... | undefined; redirect?: string | undefined; cookie?: Record<...> | undefined; }; }'.
Types of property 'code' are incompatible.
Type 'string' is not assignable to type '"INVALID_COOKIE_SIGNATURE"'.
patlux commented 1 year ago

same. I also have to import @elysiajs/eden/fetch instead of @elysiajs/eden, otherwise it returns just any.

CleanShot 2023-09-20 at 17 22 42

patlux commented 1 year ago

It was fixed with the latest release :)

MatthewAry commented 11 months ago

Still seeing some weird TS errors that I can't really make sense of when using edenTreaty.

Type 'Elysia<"", { request: { readonly prisma: () => PrismaClient<{ log: ("query" | "error")[]; }, never, DefaultArgs>; readonly bearer: string | undefined; userContext: { ...; }; }; store: {}; }, { ...; }, { ...; }, { ...; }, false>' does not satisfy the constraint 'Elysia<any, any, any, any, any, any>'.
  Types have separate declarations of a private property 'dependencies'.