Route types uses 'output' field of standard schema
Author: tscppCreated Sep 25, 2026Updated Sep 30, 2026
Labelsbug
What version of Elysia is running?
2.0.0-beta.16
What platform is your computer?
Linux 7.2.5-200.fc44.x86_64 x86_64 unknown
What environment are you using
node v26.3.0
Are you using dynamic mode?
No
What steps can reproduce the bug?
const app = new Elysia().post(
"/hello",
{
query: z.object({ number: z.coerce.number() }),
body: z.object({ number: z.coerce.number() }),
},
() => {},
);
type App = typeof app;
type Query = App["~Routes"]["hello"]["post"]["query"];
// actual: { number: number; }
// expected: { number: string; }
type Body = App["~Routes"]["hello"]["post"]["body"];
// actual: { number: number; }
// expected: { number: string; }What is the expected behavior?
You would expect the route to accept the "input" type of the schema, since that's what the route will be receiving in runtime.
https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/types.ts#L522
What do you see instead?
For example, Eden doesn't work because it expects the "output" type.
fetch("/hello", {
method: "POST",
body: {
number: "123",
// error: expected number
}
})Additional information
Switch from using "input" to "output" for standard schemas.
Example:
...
: Schema extends FastStandardSchemaV1Like
? // @ts-ignore Schema is StandardSchemaV1Like
- NonNullable<Schema['~standard']['types']>['output']
+ NonNullable<Schema['~standard']['types']>['input']
: Schema extends string
? Schema extends keyof Definitions
? Definitions[Schema] extends TAnySchema
? TImport<
// @ts-expect-error Internal typebox already filter for TSchema
Definitions,
Schema
>['static']
: // @ts-ignore Schema is StandardSchemaV1Like
NonNullable<
Definitions[Schema]['~standard']['types']
- >['output']
+ >['input']
: unknown
: unknownHave you try removing the node_modules and bun.lock and try again yet?
Yes
Source: elysiajs/elysia