v11.0.0-alpha.10
What's Changed
Standard JSON Schema
The ~standard property implements the Standard JSON Schema spec, exposing a jsonSchema converter for the schema's input and output types. Call S.enableStandardJSONSchema() once to enable it:
S.enableStandardJSONSchema();
const schema = S.string.with(S.to, S.number);
schema["~standard"].jsonSchema.input({ target: "draft-2020-12" });
// { $schema: "https://json-schema.org/draft/2020-12/schema", type: "string" }
schema["~standard"].jsonSchema.output({ target: "draft-2020-12" });
// { $schema: "https://json-schema.org/draft/2020-12/schema", type: "number" }It also adds a dedicated
StandardSchema.resbinding for ReScript users + multiple targets support forS.toJSONSchema.
Fixes & Improvements
- Fix
S.patternTS type declaration by @DZakh in #283 - Fix
S.mergeTS returned schema input type by @DZakh in #291 S.voidis now a separate schema with its own name by @DZakh in #292- Improved TS type performance by around 10x by @DZakh in #293
- Fix issue #284 by @DZakh in #290
- Fix JSON encoding of nested unions with flattened tagged objects by @DZakh in #297
- TS: Support
S.object({...})besides advanced callback form by @DZakh in #299 - TS: Support
S.tuple([...])besides advanced callback form by @DZakh in #309 - TS: Support
S.literalto help AI using Zod knowledge - this is just an alias forS.schemaby @DZakh in #309 - TS: Object schema inferred types now have optional fields at the end to match Zod behavior.
- TS:
S.schemanow automatically infers object literal fields without a need foras const.
Internal Changes
- Add declarative spec test harness for schema contracts by @DZakh in #281, #285, #298, #302, #300
- Rewrite from ReScript to TypeScript by @DZakh in #289, #296, #301, #308, #307
- Remove Wallaby.js testing infrastructure by @DZakh in #303
Full Changelog: v11.0.0-alpha.9...v11.0.0-alpha.10