Skip to content

Eden treaty converts strings to dates #251

@KuceraMartin

Description

@KuceraMartin

What version of Elysia is running?

1.4.25

What platform is your computer?

Darwin 25.2.0 arm64 arm

What steps can reproduce the bug?

import { Elysia } from 'elysia'
import { treaty } from '@elysiajs/eden'
import { z } from 'zod'

const app = new Elysia()
  .get('/test', () => "04/02/2026", {
    response: z.string()
  })

const api = treaty(app)
const res = await api.test.get()
if (res.error === null) {
  console.log(typeof res.data)
  console.log(res.data)
} else {
  console.error(res.error)
}

What is the expected behavior?

prints to console:

string
04/02/2026

What do you see instead?

prints to console:

object
2026-04-02T00:00:00.000Z

Additional information

My understanding is that Elysia tries to convert all strings that look like dates to Date objects, so what I'm describing is in some way a feature. I hope the example above illustrates why I see it as a bug. An endpoint might be returning a generic string that comes from a user's input and we don't control its format. If it happens to look like a date and we try to treat it as a string on the frontend, we have a problem.

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

No response

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