-
This code does not work. Build error:
It seems obvious to me that this should work but the documentation doesn't have anything to say about this usecase. AFAIK this is precisely how HTTP is intended to be used, especially when implementing a CRUD-like interface. I tried a few variations without success.
(I searched for similar questions but I didn't see any titles that looked promising. I might have missed something.) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Dammit I found the answer. Nevermind. |
Beta Was this translation helpful? Give feedback.
-
Seems that the "correct" solution throws out the typing information, so the handler implementation isn't type-checked. The broader type is still reflected in the generated client but the "never" type is simply gone - my 200 and 204 both use the same type:
So... I guess this library only supports the extremely common but incorrect HTTP usage. Blast. |
Beta Was this translation helpful? Give feedback.
-
Hello @felzix , this is the way: new EndpointsFactory(
new ResultHandler({
positive: (schema) => [ // <— fn argument should go here
{
statusCode: 200,
schema,
},
{
statusCode: 204,
mimeType: null,
schema: z.never(),
},
],
// ... Then there is no error. |
Beta Was this translation helpful? Give feedback.
Hello @felzix ,
this is the way:
Then there is no error.