Skip to content

Effect (v3)

If you get stuck, please try discussing the issue on the Effect Discord or posting a question to Stackoverflow. If you’ve found a bug, or Effect can’t meet your needs, please try raising an issue.

This error occurs when trying to generate an Arbitrary instance for a schema that lacks a predefined way to generate sample values. This commonly happens when the schema defines a custom type that the engine does not recognize.

To resolve this, add an arbitrary annotation that defines how to generate random instances of the custom type.

For more details, see Customizing Arbitrary Data Generation.

This error occurs when attempting to generate a JSON Schema for a type that has no direct representation in JSON Schema, such as bigint.

To resolve this, add a jsonSchema annotation to specify how the type should be represented.

For refined schemas, ensure that each refinement includes a jsonSchema annotation that describes its constraints.

For more details, see Customizing JSON Schema Generation.

This error occurs when generating a JSON Schema for a recursive or mutually recursive schema that lacks an identifier annotation.

Recursive schemas need a unique identifier annotation to ensure correct references in the generated JSON Schema. Without it, the schema generator cannot resolve the self-referencing structure.

To resolve this, ensure that recursive schemas include an identifier annotation.

For more details, see Recursive and Mutually Recursive Schemas.

This error occurs when generating a JSON Schema for a tuple that includes post-rest elements, elements appearing after a rest parameter. JSON Schema does not support this structure.

Example

import {
import Schema
Schema
} from "effect"
// Element after a rest parameter ───┐
// Rest Parameter ────────────────┐ |
// ▼ ▼
const
const schema: Schema.TupleType<readonly [], [typeof Schema.Number, typeof Schema.String]>
schema
=
import Schema
Schema
.
function Tuple<readonly [], [typeof Schema.Number, typeof Schema.String]>(elements: readonly [], rest_0: typeof Schema.Number, rest_1: typeof Schema.String): Schema.TupleType<readonly [], [typeof Schema.Number, typeof Schema.String]> (+2 overloads)

@since3.10.0

Tuple
([],
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
,
import Schema
Schema
.
class String
export String

@since3.10.0

String
)

This error occurs when attempting to generate a JSON Schema for a structure that includes unsupported key types, such as symbol. JSON Schema only supports string-based keys.

Example

import {
import Schema
Schema
} from "effect"
// Schema with a symbol key (not allowed in JSON Schema)
const
const schema: Schema.Struct<{
[x: symbol]: typeof Schema.String;
}>
schema
=
import Schema
Schema
.
function Struct<{
[x: symbol]: typeof Schema.String;
}>(fields: {
[x: symbol]: typeof Schema.String;
}): Schema.Struct<{
[x: symbol]: typeof Schema.String;
}> (+1 overload)

@since3.10.0

Struct
({
[
var Symbol: SymbolConstructor
Symbol
.
SymbolConstructor.for(key: string): symbol

Returns a Symbol object from the global symbol registry matching the given key if found. Otherwise, returns a new symbol with this key.

@paramkey key to search for.

for
("my-symbol")]:
import Schema
Schema
.
class String
export String

@since3.10.0

String
})

as there is no way to represent this in JSON Schema.

This error occurs when trying to generate a Pretty instance for a schema that lacks a predefined way to compare values. This commonly happens when the schema defines a custom type that the engine does not recognize.

To resolve this, add a pretty annotation that defines how to compare the custom type.

For more details, see Customizing Pretty Printing Generation.