-
-
Notifications
You must be signed in to change notification settings - Fork 376
Open
Labels
blockingBlocked by other issuesBlocked by other issuesbugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
1.3.5
What platform is your computer?
Darwin 24.5.0 arm64 arm
What steps can reproduce the bug?
Create Schema like this:
const Schema = t.Object({
literalArray: t.Array(t.Union((["a", "b", "c"] as const).map((x) => t.Literal(x)))),
});
and use it a body or response schema.
const app = new Elysia()
.get("/", () => "Hello Elysia")
.post(
"/test",
({ body }) => {
console.log("Received body:", body);
body.literalArray; // type never[] instead of SchemaType['literalArray']
},
{
body: Schema,
response: { 200: Schema },
}
)
.listen(3006);
What is the expected behavior?
Repsonse/Request should be validated against Schema.
Payloads/responses with
{
literalArray: ["a"]
}
should be valid.
What do you see instead?
literalArray is in response or request of type never[]
Typebox interferation works correctly:
The
type SchemaType = Static<typeof Schema>;
will result in
type SchemaType = {
literalArray: ("a" | "b" | "c")[];
}
Additional information
Reproduction: https://github.com/60pfennig/elysia-standalone-schema-bug/blob/master/src/neverBug.ts
maybe related to: #1278 ?
Creation of these Literal Union Arrays is correct according to the mainteiner: sinclairzx81/typebox#105
Have you try removing the node_modules and bun.lockb and try again yet?
yes
Metadata
Metadata
Assignees
Labels
blockingBlocked by other issuesBlocked by other issuesbugSomething isn't workingSomething isn't working