Skip to content

Symbol(TypeBox.Kind) of t.Date() is Union and not Date like in original Typebox #1107

@Necrelox

Description

@Necrelox

What version of Elysia is running?

1.2.11

What platform is your computer?

Linux 6.13.5-2-cachyos x86_64 unknown

What steps can reproduce the bug?

import { Type, TypeGuard } from '@sinclair/typebox';
import { t } from 'elysia';

const type = Type.Date();
const isDate = TypeGuard.IsDate(type);
const isUnion = TypeGuard.IsUnion(type);

console.log({ type, isDate, isUnion });
// {
//     type: {
//       [Symbol(TypeBox.Kind)]: "Date",
//       type: "Date",
//     },
//     isDate: true,
//     isUnion: false,
// }

////////////////////// With Elysia /////////////////////////////

const type2 = t.Date();
const isDate2 = TypeGuard.IsDate(type2);
const isUnion2 = TypeGuard.IsUnion(type2);

console.log({ type2, isDate2, isUnion2 });
// {
//     type2: {
//       [Symbol(TypeBox.Kind)]: "Union",
//       anyOf: [
//         [Object ...], [Object ...], [Object ...], [Object ...]
//       ],
//       [Symbol(TypeBox.Transform)]: {
//         Decode: [Function],
//         Encode: [Function],
//       },
//     },
//     isDate2: false,
//     isUnion2: true,
// }

What is the expected behavior?

import { Type, TypeGuard } from '@sinclair/typebox';
import { t } from 'elysia';

const type = Type.Date();
const isDate = TypeGuard.IsDate(type);
const isUnion = TypeGuard.IsUnion(type);

console.log({ type, isDate, isUnion });
// {
//     type: {
//       [Symbol(TypeBox.Kind)]: "Date",
//       type: "Date",
//     },
//     isDate: true,
//     isUnion: false,
// }

////////////////////// With Elysia /////////////////////////////

const type2 = t.Date();
const isDate2 = TypeGuard.IsDate(type2);
const isUnion2 = TypeGuard.IsUnion(type2);

console.log({ type2, isDate2, isUnion2 });
// {
//     type: {
//       [Symbol(TypeBox.Kind)]: "Date",
//       type: "Date",
//     },
//     isDate: true,
//     isUnion: false,
// }

What do you see instead?

in Elysia, t.Date() is an Union 😢

Additional information

No response

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