github Effect-TS/effect @effect/schema@0.67.4

latest releases: @effect/sql-sqlite-wasm@0.3.19, @effect/sql-sqlite-bun@0.4.19, @effect/schema@0.68.16...
one month ago

Patch Changes

  • #2756 ee08593 Thanks @gcanti! - Improving Predicate Usability of Schema.is

    Before this update, the Schema.is(mySchema) function couldn't be easily used as a predicate or refinement in common array methods like filter or find. This was because the function's signature was:

    (value: unknown, overrideOptions?: AST.ParseOptions) => value is A

    Meanwhile, the function expected by methods like filter has the following signature:

    (value: unknown, index: number) => value is A

    To make Schema.is compatible with these array methods, we've adjusted the function's signature to accept number as a possible value for the second parameter, in which case it is ignored:

    -(value: unknown, overrideOptions?: AST.ParseOptions) => value is A
    +(value: unknown, overrideOptions?: AST.ParseOptions | number) => value is A

    Here's a practical example comparing the behavior before and after the change:

    Before:

    import { Schema } from "@effect/schema";
    
    declare const array: Array<string | number>;
    
    /*
    Throws an error:
    No overload matches this call.
    ...
    Types of parameters 'overrideOptions' and 'index' are incompatible.
    */
    const strings = array.filter(Schema.is(Schema.String));

    Now:

    import { Schema } from "@effect/schema";
    
    declare const array: Array<string | number>;
    
    // const strings: string[]
    const strings = array.filter(Schema.is(Schema.String));

    Note that the result has been correctly narrowed to string[].

  • #2746 da6d7d8 Thanks @gcanti! - pick: do not return a ComposeTransformation if none of the picked keys are related to a property signature transformation, closes #2743

Don't miss a new effect release

NewReleases is sending notifications on new releases.