Skip to content

Value.Convert: Consider re-adding type to array coercion in v1 #1469

@lovre-nc

Description

@lovre-nc

In v0 of typebox, types were coerced to arrays when possible. In v1, this is no longer is the case.

Would you consider re-adding this to typebox? Otherwise, I would also appreciate if you can give some advice on how to best implement this ourselves.

Context:
This was very convenient for URL search params. We use @fastify/type-provider-typebox.

Previous issue and PR:
#823
#836

Reproduction (runnable as is using deno)

// v1:
import { Type, type Static } from "npm:typebox";
import { Value } from "npm:typebox/value";

// v0:
// import { Type, type Static } from "npm:@sinclair/typebox";
// import { Value } from "npm:@sinclair/typebox/value";

const result = Value.Convert(
  Type.Object({
    a: Type.Array(Type.String()),
  }),
  { a: "string" }
);

console.log("result:", result);

PS: Thank you for this awesome library and all the effort you put in. I've been using it and following the progress for years

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions