eden/treaty/parameters #672
Replies: 2 comments 2 replies
-
|
Is it planned to add type inference for query, headers? Type: |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Treaty Type inference doesn't work with Arktype. // --------- Model ---------
import { type } from "arktype";
const customer = type({
"+": "delete",
id: "string",
fullName: "string?",
email: "string?"
})
const createCustomer = customer.omit("id");
export const customerModels = new Elysia().model({
create: createCustomer,
customer: customer,
})
// --------- Server ---------
const a = new Elysia()
.use(customerModels)
.prefix("model", "customer.")
.post(
"/customer",
async function createCustomer({ body }) {
console.log(body);
},
{
body: "customer.Create",
response: "customer.Customer",
},
)
export type App = typeof a;
// --------- Client (Eden treaty) ---------
import { treaty } from '@elysiajs/eden';
const api = treaty<App>("http://localhost:3000");
await api.customer.post({
fullName: true, // <-- The type is now any
email: 123456789, // <-- Type is any, i can enter anything it throws on request
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
eden/treaty/parameters
Ergonomic Framework for Humans. TypeScript framework supercharged by Bun with End - to - End Type Safety, unified type system and outstanding developer experience
https://elysiajs.com/eden/treaty/parameters.html
Beta Was this translation helpful? Give feedback.
All reactions