Packages

effect

4.1.4 · 11 Nov 2026MIT67.1M / weekRepositoryHomepagenpmAtom feed

Your version

3.13.3

27 Feb 2025Where it was published

3.22.5 is the newest release of 3.x.

In short

2 new13 fixed8 changed

Security

2 advisories affect 3.13.3; 3.22.1 fixes them

Release note

Patch Changes

  • Schema: More Accurate Return Types for DataFromSelf and Data.

    This update refines the return types of DataFromSelf and Data, making them clearer and more specific, especially when working with structured schemas.

    Before

    The return types were more generic, making it harder to see the underlying structure:

    import { Schema } from "effect"
    
    const struct = Schema.Struct({ a: Schema.NumberFromString })
    
    //       ┌─── Schema.DataFromSelf<Schema<{ readonly a: number; }, { readonly a: string; }>>
    //       ▼
    const schema1 = Schema.DataFromSelf(struct)
    
    //       ┌─── Schema.Data<Schema<{ readonly a: number; }, { readonly a: string; }>>
    //       ▼
    const schema2 = Schema.Data(struct)

    After

    Now, the return types clearly reflect the original schema structure:

    import { Schema } from "effect"
    
    const struct = Schema.Struct({ a: Schema.NumberFromString })
    
    //       ┌─── Schema.DataFromSelf<Schema.Struct<{ a: typeof Schema.NumberFromString; }>>
    //       ▼
    const schema1 = Schema.DataFromSelf(struct)
    
    //       ┌─── Schema.Data<Schema.Struct<{ a: typeof Schema.NumberFromString; }>>
    //       ▼
    const schema2 = Schema.Data(struct)
  • Schema: More Accurate Return Type for compose.

    Before

    import { Schema } from "effect"
    
    //      ┌─── SchemaClass<number | null, string>
    //      ▼
    const schema = Schema.compose(
      Schema.NumberFromString,
      Schema.NullOr(Schema.Number)
    )
    
    // @ts-expect-error: Property 'from' does not exist
    schema.from
    
    // @ts-expect-error: Property 'to' does not exist
    schema.to

    After

    import { Schema } from "effect"
    
    //      ┌─── transform<typeof Schema.NumberFromString, Schema.NullOr<typeof Schema.Number>>
    //      ▼
    const schema = Schema.compose(
      Schema.NumberFromString,
      Schema.NullOr(Schema.Number)
    )
    
    //      ┌─── typeof Schema.NumberFromString
    //      ▼
    schema.from
    
    //      ┌─── Schema.NullOr<typeof Schema.Number>
    //      ▼
    schema.to
  • Schema: More precise return types when filters are involved.

    Example (with Schema.maxLength)

    Before

    import { Schema } from "effect"
    
    //      ┌─── Schema.filter<Schema.Schema<string, string, never>>
    //      ▼
    const schema = Schema.String.pipe(Schema.maxLength(10))
    
    // Schema<string, string, never>
    schema.from

    After

    import { Schema } from "effect"
    
    //      ┌─── Schema.filter<typeof Schema.String>
    //      ▼
    const schema = Schema.String.pipe(Schema.maxLength(10))
    
    // typeof Schema.String
    schema.from

    String filters:

    • maxLength

    • minLength

    • length

    • pattern

    • startsWith

    • endsWith

    • includes

    • lowercased

    • capitalized

    • uncapitalized

    • uppercased

    • nonEmptyString

    • trimmed

    Number filters:

    • finite

    • greaterThan

    • greaterThanOrEqualTo

    • lessThan

    • lessThanOrEqualTo

    • int

    • multipleOf

    • between

    • nonNaN

    • positive

    • negative

    • nonPositive

    • nonNegative

    BigInt filters:

    • greaterThanBigInt

    • greaterThanOrEqualToBigInt

    • lessThanBigInt

    • lessThanOrEqualToBigInt

    • betweenBigInt

    • positiveBigInt

    • negativeBigInt

    • nonNegativeBigInt

    • nonPositiveBigInt

    Duration filters:

    • lessThanDuration

    • lessThanOrEqualToDuration

    • greaterThanDuration

    • greaterThanOrEqualToDuration

    • betweenDuration

    Array filters:

    • minItems

    • maxItems

    • itemsCount

    Date filters:

    • validDate

    • lessThanDate

    • lessThanOrEqualToDate

    • greaterThanDate

    • greaterThanOrEqualToDate

    • betweenDate

    BigDecimal filters:

    • greaterThanBigDecimal

    • greaterThanOrEqualToBigDecimal

    • lessThanBigDecimal

    • lessThanOrEqualToBigDecimal

    • positiveBigDecimal

    • nonNegativeBigDecimal

    • negativeBigDecimal

    • nonPositiveBigDecimal

    • betweenBigDecimal

  • Schema: More Accurate Return Types for ArrayEnsure and NonEmptyArrayEnsure.

    Before

    import { Schema } from "effect"
    
    const schema1 = Schema.ArrayEnsure(Schema.String)
    
    // @ts-expect-error: Property 'from' does not exist
    schema1.from
    
    const schema2 = Schema.NonEmptyArrayEnsure(Schema.String)
    
    // @ts-expect-error: Property 'from' does not exist
    schema2.from

    After

    import { Schema } from "effect"
    
    const schema1 = Schema.ArrayEnsure(Schema.String)
    
    //        ┌─── Schema.Union<[typeof Schema.String, Schema.Array$<typeof Schema.String>]>
    //        ▼
    schema1.from
    
    const schema2 = Schema.NonEmptyArrayEnsure(Schema.String)
    
    //        ┌─── Schema.Union<[typeof Schema.String, Schema.NonEmptyArray<typeof Schema.String>]>
    //        ▼
    schema2.from
  • Schema: More Accurate Return Types for:

    • transformLiteral

    • clamp

    • clampBigInt

    • clampDuration

    • clampBigDecimal

    • head

    • headNonEmpty

    • headOrElse

  • Schema: More Accurate Return Type for parseNumber.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.parseNumber(Schema.String)
    
    //      ┌─── Schema<string>
    //      ▼
    schema.from

    After

    import { Schema } from "effect"
    
    const schema = Schema.parseNumber(Schema.String)
    
    //      ┌─── typeof Schema.String
    //      ▼
    schema.from
  • Fix nested batching

  • Schema: Add missing from property to brand interface.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.String.pipe(Schema.brand("my-brand"))
    
    // @ts-expect-error: Property 'from' does not exist
    schema.from

    After

    import { Schema } from "effect"
    
    const schema = Schema.String.pipe(Schema.brand("my-brand"))
    
    //      ┌─── typeof Schema.String
    //      ▼
    schema.from
  • Ensure fibers can't be added to Fiber{Handle,Set,Map} during closing

  • Fix Context.Tag unification

  • Simplify sortWith, sort, reverse, sortBy, unzip, dedupe signatures in Array module

  • Schema: More Accurate Return Type for parseJson(schema).

    Before

    import { Schema } from "effect"
    
    //      ┌─── Schema.SchemaClass<{ readonly a: number; }, string>
    //      ▼
    const schema = Schema.parseJson(
      Schema.Struct({
        a: Schema.NumberFromString
      })
    )
    
    // @ts-expect-error: Property 'to' does not exist
    schema.to

    After

    import { Schema } from "effect"
    
    //      ┌─── Schema.transform<Schema.SchemaClass<unknown, string, never>, Schema.Struct<{ a: typeof Schema.NumberFromString; }>>
    //      ▼
    const schema = Schema.parseJson(
      Schema.Struct({
        a: Schema.NumberFromString
      })
    )
    
    //      ┌─── Schema.Struct<{ a: typeof Schema.NumberFromString; }>
    //      ▼
    schema.to
  • Refactor JSONSchema to use additionalProperties instead of patternProperties for simple records, closes #4518.

    This update improves how records are represented in JSON Schema by replacing patternProperties with additionalProperties, resolving issues in OpenAPI schema generation.

    Why the change?

    • Fixes OpenAPI issues – Previously, records were represented using patternProperties, which caused problems with OpenAPI tools.

    • Better schema compatibility – Some tools, like openapi-ts, struggled with patternProperties, generating Record<string, never> instead of the correct type.

    • Fixes missing example values – When using patternProperties, OpenAPI failed to generate proper response examples, displaying only {}.

    • Simplifies schema modification – Users previously had to manually fix schemas with OpenApi.Transform, which was messy and lacked type safety.

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Record({ key: Schema.String, value: Schema.Number })
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "required": [],
      "properties": {},
      "patternProperties": {
        "": { // ❌ Empty string pattern
          "type": "number"
        }
      }
    }
    */

    After

    Now, additionalProperties is used instead, which properly represents an open-ended record:

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Record({ key: Schema.String, value: Schema.Number })
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "required": [],
      "properties": {},
      "additionalProperties": { // ✅ Represents unrestricted record keys
        "type": "number"
      }
    }
    */
  • Schema: Add Missing declare API Interface to Expose Type Parameters.

    Example

    import { Schema } from "effect"
    
    const schema = Schema.OptionFromSelf(Schema.String)
    
    //       ┌─── readonly [typeof Schema.String]
    //       ▼
    schema.typeParameters
  • Schema: More precise return types when transformations are involved.

    • Chunk

    • NonEmptyChunk

    • Redacted

    • Option

    • OptionFromNullOr

    • OptionFromUndefinedOr

    • OptionFromNullishOr

    • Either

    • EitherFromUnion

    • ReadonlyMap

    • Map

    • HashMap

    • ReadonlySet

    • Set

    • HashSet

    • List

    • Cause

    • Exit

    • SortedSet

    • head

    • headNonEmpty

    • headOrElse

    Example (with Schema.Chunk)

    Before

    import { Schema } from "effect"
    
    const schema = Schema.Chunk(Schema.Number)
    
    // Property 'from' does not exist on type 'Chunk<typeof Number$>'
    schema.from

    After

    import { Schema } from "effect"
    
    const schema = Schema.Chunk(Schema.Number)
    
    // Schema.Array$<typeof Schema.Number>
    schema.from
  • Schema: Improve Literal return type — now returns SchemaClass instead of Schema

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.