-
-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
No response
What platform is your computer?
No response
What steps can reproduce the bug?
Try on https://elysiajs.com/playground:
import { Elysia } from 'elysia';
import { StandardSchemaV1Like } from 'elysia/types';
import { treaty } from '@elysiajs/eden';
import * as z from 'zod';
const QuerySchema = z.object({
name: z.string().default("World"),
});
const app = new Elysia()
.get('/', ({ query: { name } }) => `Hello ${name}!`, { query: QuerySchema })
.listen(3000);
const api = treaty(app);
api.get({ query: { name: "Elysia" } });
// TS ERROR, SHOULD WORK
api.get({ query: {} });
// Zod:
// type QueryInput = z.input<typeof QuerySchema>;
// Standard Schema: https://github.com/standard-schema/standard-schema#the-interface
export type InferInput<Schema extends StandardSchemaV1Like> = NonNullable<
Schema['~standard']['types']
>['input'];
export type QueryInput = InferInput<typeof QuerySchema>;
const query: QueryInput = {};
// TS ERROR, SHOULD WORK
api.get({ query });What is the expected behavior?
No response
What do you see instead?
No response
Additional information
See:
- https://github.com/standard-schema/standard-schema#the-interface
- https://zod.dev/basics?id=inferring-types
Have you try removing the node_modules and bun.lockb and try again yet?
No response
tinchoz49, RainyPixel, zihaolam and heiwen
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working