We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
treaty
guard
response
{ "@elysiajs/eden": "^1.0.14", "@elysiajs/swagger": "^1.0.5", "elysia": "^1.0.22" }
import { treaty } from "@elysiajs/eden"; import { swagger } from "@elysiajs/swagger"; import { Elysia, t } from "elysia"; const app = new Elysia() .use(swagger()) .guard( { response: { 418: t.Union([t.Literal("foo"), t.Literal("bar")]), }, }, (app) => app .onBeforeHandle(async ({ set }) => { if (Math.random() > 0.5) { set.status = 418; return "foo"; } }) .onBeforeHandle(async ({ set }) => { if (Math.random() > 0.5) { set.status = 418; return "bar"; } }) .get("/test", () => 1, { response: { 200: t.Number(), }, }) ) .listen(8080); const client = treaty<typeof app>(app.server!.url.toString()); const { error } = await client.test.get(); if (error) { type Err = typeof error; // <--- }
Err has type {status: unknown, value: unknown} instead of {status: 418, value: "foo" | "bar"}
Err
{status: unknown, value: unknown}
{status: 418, value: "foo" | "bar"}
adding type to handler works as expected:
.get("/test", () => 1, { response: { 200: t.Number(), 418: t.Union([t.Literal("foo"), t.Literal("bar")]), }, })
reported on discord
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Dependencies
Code
Err
has type{status: unknown, value: unknown}
instead of{status: 418, value: "foo" | "bar"}
Additional Informations
adding type to handler works as expected:
reported on discord
The text was updated successfully, but these errors were encountered: