Skip to content

bug: eden treaty - request body params has any type - eden fetch has correct types #1666

@tresorama

Description

@tresorama

What version of Elysia is running?

├── @elysiajs/[email protected]
├── @elysiajs/[email protected]
├── @types/[email protected]
├── [email protected]
├── [email protected]
└── [email protected]

What platform is your computer?

Linux VM

What environment are you using

node v22.20.0

Are you using dynamic mode?

no

What steps can reproduce the bug?

See sandbox

  • Create a route that requires a request body
  • create an eden treaty client
  • call the route with the client and note that body params has any as type
  • create an eden fetch client
  • do same -> note that eden fetch client has correct type

Visual

// backend api
new Elysia
.post(
    "/create-post",
    async (ctx) => {
      return {
        message: "Post Created",
        data: ctx.body,
      };
    },
    {
      body: t.Object({
        name: t.String(),
        content: t.String(),
        safeAge: t.Number(),
      }),
    },
// client 

const clientTreaty = ...
const clientFetch = ...

// eden treaty is bugged
await clientTreaty.['create-post'].post({
  // here property names are correct, but every props types is any
})

// eden fetch is correct
await clientFetch('/create-post', {
  method: 'POST',
  body: {
    // here property names and types are correct
  }
);

What is the expected behavior?

correct types

What do you see instead?

any type for each body param

Additional information

See sandbox

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