Releases: Effect-TS/effect
Releases · Effect-TS/effect
[email protected]
Patch Changes
-
#4610
0c4803f
Thanks @gcanti! - Preserve specific annotations (e.g.,arbitrary
) when usingSchema.typeSchema
, closes #4609.Previously, annotations such as
arbitrary
were lost when callingSchema.typeSchema
on a transformation. This update ensures that certain annotations, which depend only on the "to" side of the transformation, are preserved.Annotations that are now retained:
examples
default
jsonSchema
arbitrary
pretty
equivalence
Example
Before
import { Arbitrary, FastCheck, Schema } from "effect" const schema = Schema.NumberFromString.annotations({ arbitrary: () => (fc) => fc.constant(1) }) const to = Schema.typeSchema(schema) // ❌ Annotation is lost console.log(FastCheck.sample(Arbitrary.make(to), 5)) /* [ 2.5223372357846707e-44, -2.145443957806771e+25, -3.4028179901346956e+38, 5.278086259208735e+29, 1.8216880036222622e-44 ] */
After
import { Arbitrary, FastCheck, Schema } from "effect" const schema = Schema.NumberFromString.annotations({ arbitrary: () => (fc) => fc.constant(1) }) const to = Schema.typeSchema(schema) // ✅ Annotation is now preserved console.log(FastCheck.sample(Arbitrary.make(to), 5)) /* [ 1, 1, 1, 1, 1 ] */
-
#4607
6f65ac4
Thanks @gcanti! - Add support forjsonSchema
annotations onSymbolFromSelf
index signatures.Before
import { JSONSchema, Schema } from "effect" const schema = Schema.Record({ key: Schema.SymbolFromSelf.annotations({ jsonSchema: { type: "string" } }), value: Schema.Number }) JSONSchema.make(schema) /* throws: Error: Unsupported index signature parameter schema (SymbolKeyword): symbol */
After
import { JSONSchema, Schema } from "effect" const schema = Schema.Record({ key: Schema.SymbolFromSelf.annotations({ jsonSchema: { type: "string" } }), value: Schema.Number }) console.log(JSON.stringify(JSONSchema.make(schema), null, 2)) /* Output: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": [], "properties": {}, "additionalProperties": { "type": "number" }, "propertyNames": { "type": "string" } } */
@effect/[email protected]
@effect/[email protected]
@effect/[email protected]
Patch Changes
- Updated dependencies [
0c4803f
,6f65ac4
]:- [email protected]
- @effect/[email protected]
- @effect/[email protected]
@effect/[email protected]
Patch Changes
- Updated dependencies [
0c4803f
,6f65ac4
]:- [email protected]
- @effect/[email protected]
- @effect/[email protected]
@effect/[email protected]
Patch Changes
- Updated dependencies [
0c4803f
,6f65ac4
]:- [email protected]
- @effect/[email protected]
- @effect/[email protected]
@effect/[email protected]
Patch Changes
- Updated dependencies [
0c4803f
,6f65ac4
]:- [email protected]
- @effect/[email protected]
- @effect/[email protected]
- @effect/[email protected]
@effect/[email protected]
Patch Changes
- Updated dependencies [
0c4803f
,6f65ac4
]:- [email protected]
- @effect/[email protected]
- @effect/[email protected]
@effect/[email protected]
Patch Changes
- Updated dependencies [
0c4803f
,6f65ac4
]:- [email protected]
- @effect/[email protected]
- @effect/[email protected]
- @effect/[email protected]
@effect/[email protected]
Patch Changes
- Updated dependencies [
0c4803f
,6f65ac4
]:- [email protected]
- @effect/[email protected]
- @effect/[email protected]
- @effect/[email protected]