-
-
Notifications
You must be signed in to change notification settings - Fork 494
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
1.4.28
What platform is your computer?
Darwin 23.6.0 arm64 arm
What environment are you using
bun 1.3.8
Are you using dynamic mode?
no
What steps can reproduce the bug?
import { Elysia, t, type UnwrapBodySchema } from "elysia";
import { treaty } from "@elysiajs/eden";
// TypeBox Mocked Transform
const Base64 = t
.Transform(t.String({ description: "Base64-encoded Uint8Array" }))
.Decode((base64: string): Uint8Array => new Uint8Array())
.Encode((bytes: Uint8Array): string => "");
const app = new Elysia()
.post("/register", ({ body: { key } }) => ({ success: true }), // (parameter) key: Uint8Array
{
body: t.Object({
key: Base64, // (property) key: TTransform<TString, Uint8Array>
}),
}
)
.listen(3000);
// ~Routes always stores decoded/output types — input types are lost
type RegisterBody = (typeof app)["~Routes"]["register"]["post"]["body"];
// type RegisterBody = { key: Uint8Array } <- should be { key: string }
type TypeBoxResult = UnwrapBodySchema<typeof Base64>;
// type TypeBoxResult = Uint8Array <- should be string
// ---
const api = treaty(app);
// Type 'string' is not assignable to type 'Uint8Array'
await api.register.post({ key: "someBase64String" });What is the expected behavior?
~Routes should expose both input (wire) and output (decoded) types for each route, so consumers like @elysiajs/eden can infer the correct client-side types. For a route with t.Transform(t.String()).Decode(...), the body input type should be string.
What do you see instead?
~Routes only stores decoded/output types. For a route with t.Transform(t.String()).Decode((v): Uint8Array => ...), the body type is inferred as Uint8Array instead of string, forcing @elysiajs/eden to require the decoded type on the client side.
Additional information
@elysiajs/eden: 1.4.8
Have you try removing the node_modules and bun.lockb and try again yet?
yes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working