effect@3.11.10
Patch Changes
-
#4176
39457d4Thanks @mikearnaldi! - Fix Stream.scoped example -
#4181
a475cc2Thanks @gcanti! - Schema: FixwithDecodingDefaultimplementation to align with its signature (now removesundefinedfrom the AST).Additionally, a new constraint has been added to the signature to prevent calling
withDecodingDefaultafterwithConstructorDefault, which previously led to the following issue:import { Schema } from "effect" const schema = Schema.Struct({ a: Schema.optional(Schema.String).pipe( Schema.withConstructorDefault(() => undefined), // this is invalidated by the following call to `withDecodingDefault` Schema.withDecodingDefault(() => "") ) })
-
#4175
199214eThanks @gcanti! - Schema: refactor annotations:-
Export internal
Uint8schema -
Export internal
NonNegativeIntschema -
Remove title annotations that are identical to identifiers
-
Avoid setting a title annotation when applying branding
-
Add more title annotations to refinements
-
Improve
toStringoutput and provide more precise error messages for refinements:Before
import { Schema } from "effect" const schema = Schema.Number.pipe( Schema.int({ identifier: "MyInt" }), Schema.positive() ) console.log(String(schema)) // Output: a positive number Schema.decodeUnknownSync(schema)(1.1) /* throws: ParseError: a positive number └─ From side refinement failure └─ MyInt └─ Predicate refinement failure └─ Expected MyInt, actual 1.1 */
After
toStringnow combines all refinements with" & "instead of showing only the last one.- The last message (
"Expected ...") now uses the extended description to make the error message clearer.
import { Schema } from "effect" const schema = Schema.Number.pipe( Schema.int({ identifier: "MyInt" }), Schema.positive() ) console.log(String(schema)) // Output: MyInt & positive // <= all the refinements Schema.decodeUnknownSync(schema)(1.1) /* throws: ParseError: MyInt & positive └─ From side refinement failure └─ MyInt └─ Predicate refinement failure └─ Expected an integer, actual 1.1 // <= extended description */
-
-
#4182
b3c160dThanks @mikearnaldi! - Replace absolute imports with relative ones