Skip to content

Status Code 200 Breaks Type Inference in ~Routes with Zod #1548

@Vicentesan

Description

@Vicentesan

What version of Elysia is running?

1.4.16

What platform is your computer?

Darwin 25.1.0 arm64 arm

What environment are you using

bun 1.3.2

Are you using dynamic mode?

no

What steps can reproduce the bug?

  1. clone this repository
  2. run bun install
  3. open the src/index.ts file and hover over the AppResponse and AppTwoResponse types

What is the expected behavior?

elysia is expected to infer the zod response type even for the 200 status code and ensure it is fully type-safe

so, it would output something like:

type AppResponse = {
    200: {
        message: "Hello Elysia";
    };
    422: {
        type: "validation";
        on: string;
        summary?: string;
        message?: string;
        found?: unknown;
        property?: string;
        expected?: string;
    };
}

What do you see instead?

type AppResponse = {
    [x: string]: any;
    [x: number]: any;
    [x: symbol]: any;
}

Additional information

this issue is not reproducible in elysia versions 1.4.0 to 1.4.13. in elysia version 1.4.14 and later, it breaks, as i reported here

Have you try removing the node_modules and bun.lockb and try again yet?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions