effect
4.1.4 · 11 Nov 2026MIT67.1M / weekRepositoryHomepagenpmAtom feed
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
- HighEffect: ReDoS in Schema.TemplateLiteral compiled regexGHSA-7589-6fvf-x4pw · 19 Nov 2026Fixed in 3.22.1
- HighEffect `AsyncLocalStorage` context lost/contaminated inside Effect fibers under concurrent load with RPCGHSA-38f7-945m-qr2g · 20 Mar 2026Fixed in 3.20.0
Release note
Patch Changes
Schema: More Accurate Return Types for
DataFromSelfandData.This update refines the return types of
DataFromSelfandData, 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.toAfter
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.toSchema: 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.fromAfter
import { Schema } from "effect" // ┌─── Schema.filter<typeof Schema.String> // ▼ const schema = Schema.String.pipe(Schema.maxLength(10)) // typeof Schema.String schema.fromString filters:
maxLengthminLengthlengthpatternstartsWithendsWithincludeslowercasedcapitalizeduncapitalizeduppercasednonEmptyStringtrimmed
Number filters:
finitegreaterThangreaterThanOrEqualTolessThanlessThanOrEqualTointmultipleOfbetweennonNaNpositivenegativenonPositivenonNegative
BigInt filters:
greaterThanBigIntgreaterThanOrEqualToBigIntlessThanBigIntlessThanOrEqualToBigIntbetweenBigIntpositiveBigIntnegativeBigIntnonNegativeBigIntnonPositiveBigInt
Duration filters:
lessThanDurationlessThanOrEqualToDurationgreaterThanDurationgreaterThanOrEqualToDurationbetweenDuration
Array filters:
minItemsmaxItemsitemsCount
Date filters:
validDatelessThanDatelessThanOrEqualToDategreaterThanDategreaterThanOrEqualToDatebetweenDate
BigDecimal filters:
greaterThanBigDecimalgreaterThanOrEqualToBigDecimallessThanBigDecimallessThanOrEqualToBigDecimalpositiveBigDecimalnonNegativeBigDecimalnegativeBigDecimalnonPositiveBigDecimalbetweenBigDecimal
Schema: More Accurate Return Types for
ArrayEnsureandNonEmptyArrayEnsure.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.fromAfter
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.fromSchema: More Accurate Return Types for:
transformLiteralclampclampBigIntclampDurationclampBigDecimalheadheadNonEmptyheadOrElse
Schema: More Accurate Return Type for
parseNumber.Before
import { Schema } from "effect" const schema = Schema.parseNumber(Schema.String) // ┌─── Schema<string> // ▼ schema.fromAfter
import { Schema } from "effect" const schema = Schema.parseNumber(Schema.String) // ┌─── typeof Schema.String // ▼ schema.fromFix nested batching
Schema: Add missing
fromproperty tobrandinterface.Before
import { Schema } from "effect" const schema = Schema.String.pipe(Schema.brand("my-brand")) // @ts-expect-error: Property 'from' does not exist schema.fromAfter
import { Schema } from "effect" const schema = Schema.String.pipe(Schema.brand("my-brand")) // ┌─── typeof Schema.String // ▼ schema.fromEnsure fibers can't be added to Fiber{Handle,Set,Map} during closing
Fix Context.Tag unification
Simplify
sortWith,sort,reverse,sortBy,unzip,dedupesignatures in Array moduleSchema: 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.toAfter
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.toRefactor
JSONSchemato useadditionalPropertiesinstead ofpatternPropertiesfor simple records, closes #4518.This update improves how records are represented in JSON Schema by replacing
patternPropertieswithadditionalProperties, 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 withpatternProperties, generatingRecord<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,
additionalPropertiesis 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
declareAPI Interface to Expose Type Parameters.Example
import { Schema } from "effect" const schema = Schema.OptionFromSelf(Schema.String) // ┌─── readonly [typeof Schema.String] // ▼ schema.typeParametersSchema: More precise return types when transformations are involved.
ChunkNonEmptyChunkRedactedOptionOptionFromNullOrOptionFromUndefinedOrOptionFromNullishOrEitherEitherFromUnionReadonlyMapMapHashMapReadonlySetSetHashSetListCauseExitSortedSetheadheadNonEmptyheadOrElse
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.fromAfter
import { Schema } from "effect" const schema = Schema.Chunk(Schema.Number) // Schema.Array$<typeof Schema.Number> schema.fromSchema: Improve
Literalreturn type — now returnsSchemaClassinstead ofSchema
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.