ardatan/feTS

Missing POST json body not considered a TS error

dodas opened this issue · 2 comments

dodas commented

Consider following route:

const router = createRouter().route({
  method: "POST",
  path: "/hello",
  handler: () => Response.json("hi"),
  schemas: {
    request: {
      json: Type.Object({
        name: Type.String(),
      }),
    },
  },
});

Calling this route without json raises no error about missing json with name property:

client["/hello"].post(); // < No error

However, when json property is present, but name is missing, error is correctly raised:

client["/hello"].post({
  json: {}, // < Property 'name' is missing in type '{}' but required in type '{ name: string; }'.ts(2741)
});
m4rvr commented

This seems like a similar issue here, but with the params instead #896

Fixed by #912
Thanks for the issue!