estephinson / zod-wretch

A small library bringing in Zod Schema parsing to the Wretch callchain
0 stars 1 forks source link

Type error when using other addons #2

Open biesbjerg opened 8 months ago

biesbjerg commented 8 months ago

Hello!

Neat addon :-)

I'm trying to use it with other addons, but something is off with the types.

Reproduction:

const api = wretch().addon(ZodAddon).addon(queryStringAddon);

const schema = z.object({ message: z.string() });
const response = await api.get("/test").jsonSchema(schema);
The 'this' context of type 'ZodAddon & WretchResponseChain<QueryStringAddon, ZodAddon, undefined>' is not assignable to method's 'this' of type 'QueryStringAddon & WretchResponseChain<QueryStringAddon, ZodAddon, undefined>'.
  Property 'query' is missing in type 'ZodAddon & WretchResponseChain<QueryStringAddon, ZodAddon, undefined>' but required in type 'QueryStringAddon'.ts(2684)

If I remove the queryStringAddon the error goes away — I haven't been able to solve it, so was hoping you had an idea?

biesbjerg commented 8 months ago

Turns out it was an easy fix — opened a PR: https://github.com/estephinson/zod-wretch/pull/3