-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
good first issueGood for newcomersGood for newcomerstypescriptRelated to TypeScript APIRelated to TypeScript API
Description
Hi,
I am testing different libraries that implement the Standard Schema interface to figure out which library to use in my app.
While testing version 11.0.0-alpha.4 of your library, I noticed a difference in output between your library and Zod and Valibot's library.
Using your library, I created a schema with optional properties:
export const SDocMeta = S.schema({
_id: S.optional(S.string),
_rev: S.optional(S.string),
_deleted: S.optional(S.boolean),
})
export type SDocMeta = S.Output<typeof SDocMeta>As expected, the properties of typeof SDocMeta are optional:
{
_id?: string | undefined
_rev?: string | undefined
_deleted?: boolean | undefined
}I then merge this schema with another:
export const Product = S.merge(SDocMeta, S.schema({
code: S.min(S.string, 1, 'Product Code is required'),
name: S.min(S.string, 1, 'Product Name is required'),
}))
export type Product = S.Output<typeof Product>Unexpectedly, typeof Product becomes...
{
_id: string | undefined
_rev: string | undefined
_deleted: boolean | undefined
code: string
name: string
}...where the properties of SDocMeta are no longer optional.
This is different from Zod and Valibot's library. In those libraries, the optional properties stay optional after merging/extending a schema.
May you consider matching the behaviour of Zod and Valibot's library? Thanks!
SX-3
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomerstypescriptRelated to TypeScript APIRelated to TypeScript API