Skip to content
Effect Days 2026 Get your ticket

SchemaAST

157 exports Added in v3.10.0 Source

Annotations

Annotated interface

Added in v3.10.0 Source

Signature

interface Annotated {
readonly annotations: Annotations;
}

Annotations interface

Added in v3.10.0 Source

Signature

interface Annotations {
[_: string]: unknown;
[_: symbol]: unknown;
}

Signature

declare const ArbitraryAnnotationId: unique symbol

BatchingAnnotation type

Added in v3.10.0 Source

Signature

type BatchingAnnotation = boolean | "inherit" | undefined

Signature

declare const BatchingAnnotationId: unique symbol

BrandAnnotation type

Added in v3.10.0 Source

Signature

type BrandAnnotation = Arr.NonEmptyReadonlyArray<string | symbol>

Signature

declare const BrandAnnotationId: unique symbol

ConcurrencyAnnotation type

Added in v3.10.0 Source

Signature

type ConcurrencyAnnotation = Concurrency | undefined

Signature

declare const ConcurrencyAnnotationId: unique symbol

Signature

type DecodingFallbackAnnotation<A> = (issue: ParseIssue) => Effect<A, ParseIssue>

Signature

declare const DecodingFallbackAnnotationId: unique symbol

DefaultAnnotation type

Added in v3.10.0 Source

Signature

type DefaultAnnotation<A> = A

Signature

declare const DefaultAnnotationId: unique symbol

DescriptionAnnotation type

Added in v3.10.0 Source

Signature

type DescriptionAnnotation = string

Signature

declare const DescriptionAnnotationId: unique symbol

Signature

type DocumentationAnnotation = string

Signature

declare const DocumentationAnnotationId: unique symbol

EquivalenceAnnotation type

Added in v3.10.0 Source

Signature

type EquivalenceAnnotation<A, TypeParameters extends ReadonlyArray<any> = readonly []> = (...equivalences: { [K in keyof TypeParameters]: Equivalence<TypeParameters[K]> }) => Equivalence<A>

Signature

declare const EquivalenceAnnotationId: unique symbol

ExamplesAnnotation type

Added in v3.10.0 Source

Signature

type ExamplesAnnotation<A> = Arr.NonEmptyReadonlyArray<A>

Signature

declare const ExamplesAnnotationId: unique symbol

getAnnotation

Added in v3.10.0 Source

Signature

declare const getAnnotation: {
<A>(key: symbol): (annotated: Annotated) => Option<A>;
<A>(annotated: Annotated, key: symbol): Option<A>;
}

Signature

declare const getBatchingAnnotation: (annotated: Annotated) => Option<BatchingAnnotation>

Signature

declare const getBrandAnnotation: (annotated: Annotated) => Option<readonly [string | symbol, string | symbol]>

Signature

declare const getConcurrencyAnnotation: (annotated: Annotated) => Option<ConcurrencyAnnotation>

Signature

declare const getDecodingFallbackAnnotation: (annotated: Annotated) => Option<DecodingFallbackAnnotation<unknown>>

Signature

declare const getDefaultAnnotation: (annotated: Annotated) => Option<unknown>

Signature

declare const getDescriptionAnnotation: (annotated: Annotated) => Option<string>

Signature

declare const getDocumentationAnnotation: (annotated: Annotated) => Option<string>

Signature

declare const getExamplesAnnotation: (annotated: Annotated) => Option<readonly [unknown, unknown]>

Signature

declare const getIdentifierAnnotation: (annotated: Annotated) => Option<string>

Signature

declare function getJSONIdentifier(annotated: Annotated): Option<string>

Signature

declare const getJSONIdentifierAnnotation: (annotated: Annotated) => Option<string>

Signature

declare const getJSONSchemaAnnotation: (annotated: Annotated) => Option<object>

Signature

declare const getMessageAnnotation: (annotated: Annotated) => Option<MessageAnnotation>

Signature

declare const getMissingMessageAnnotation: (annotated: Annotated) => Option<MissingMessageAnnotation>

Signature

declare const getParseIssueTitleAnnotation: (annotated: Annotated) => Option<ParseIssueTitleAnnotation>

Signature

declare const getParseOptionsAnnotation: (annotated: Annotated) => Option<ParseOptions>

Signature

declare const getSchemaIdAnnotation: (annotated: Annotated) => Option<SchemaIdAnnotation>

Signature

declare const getSurrogateAnnotation: (annotated: Annotated) => Option<AST>

Signature

declare const getTitleAnnotation: (annotated: Annotated) => Option<string>

Signature

declare const getTypeConstructorAnnotation: (annotated: Annotated) => Option<TypeConstructorAnnotation>

IdentifierAnnotation type

Added in v3.10.0 Source

Signature

type IdentifierAnnotation = string

Signature

declare const IdentifierAnnotationId: unique symbol

Signature

declare const JSONIdentifierAnnotationId: unique symbol

JSONSchemaAnnotation type

Added in v3.10.0 Source

Signature

type JSONSchemaAnnotation = object

Signature

declare const JSONSchemaAnnotationId: unique symbol

MessageAnnotation type

Added in v3.10.0 Source

Signature

type MessageAnnotation = (issue: ParseIssue) => string | Effect<string> | {
readonly message: string | Effect<string>;
readonly override: boolean;
}

Signature

declare const MessageAnnotationId: unique symbol

Signature

type MissingMessageAnnotation = () => string | Effect<string>

Signature

declare const MissingMessageAnnotationId: unique symbol

Signature

type ParseIssueTitleAnnotation = (issue: ParseIssue) => string | undefined

Signature

declare const ParseIssueTitleAnnotationId: unique symbol

Signature

declare const ParseOptionsAnnotationId: unique symbol

Signature

declare const PrettyAnnotationId: unique symbol

SchemaIdAnnotation type

Added in v3.10.0 Source

Signature

type SchemaIdAnnotation = string | symbol

Signature

declare const SchemaIdAnnotationId: unique symbol

SurrogateAnnotation type

Added in v3.10.0 Source

Signature

type SurrogateAnnotation = AST

Signature

declare const SurrogateAnnotationId: unique symbol

TitleAnnotation type

Added in v3.10.0 Source

Signature

type TitleAnnotation = string

Signature

declare const TitleAnnotationId: unique symbol

Signature

type TypeConstructorAnnotation = {
[key: string | number | symbol]: unknown;
readonly _tag: string;
}

Signature

declare const TypeConstructorAnnotationId: unique symbol

Constructors

anyKeyword

Added in v3.10.0 Source

Signature

declare const anyKeyword: AnyKeyword

bigIntKeyword

Added in v3.10.0 Source

Signature

declare const bigIntKeyword: BigIntKeyword

booleanKeyword

Added in v3.10.0 Source

Signature

declare const booleanKeyword: BooleanKeyword

Signature

declare const composeTransformation: ComposeTransformation

neverKeyword

Added in v3.10.0 Source

Signature

declare const neverKeyword: NeverKeyword

numberKeyword

Added in v3.10.0 Source

Signature

declare const numberKeyword: NumberKeyword

objectKeyword

Added in v3.10.0 Source

Signature

declare const objectKeyword: ObjectKeyword

stringKeyword

Added in v3.10.0 Source

Signature

declare const stringKeyword: StringKeyword

symbolKeyword

Added in v3.10.0 Source

Signature

declare const symbolKeyword: SymbolKeyword

Signature

declare const undefinedKeyword: UndefinedKeyword

unknownKeyword

Added in v3.10.0 Source

Signature

declare const unknownKeyword: UnknownKeyword

voidKeyword

Added in v3.10.0 Source

Signature

declare const voidKeyword: VoidKeyword

Guards

isAnyKeyword

Added in v3.10.0 Source

Signature

declare const isAnyKeyword: (ast: AST) => ast is AnyKeyword

Signature

declare const isBigIntKeyword: (ast: AST) => ast is BigIntKeyword

Signature

declare const isBooleanKeyword: (ast: AST) => ast is BooleanKeyword

Signature

declare const isComposeTransformation: (ast: TransformationKind) => ast is ComposeTransformation

isDeclaration

Added in v3.10.0 Source

Signature

declare const isDeclaration: (ast: AST) => ast is Declaration

isEnums

Added in v3.10.0 Source

Signature

declare const isEnums: (ast: AST) => ast is Enums

Signature

declare const isFinalTransformation: (ast: TransformationKind) => ast is FinalTransformation

isLiteral

Added in v3.10.0 Source

Signature

declare const isLiteral: (ast: AST) => ast is Literal

isNeverKeyword

Added in v3.10.0 Source

Signature

declare const isNeverKeyword: (ast: AST) => ast is NeverKeyword

Signature

declare const isNumberKeyword: (ast: AST) => ast is NumberKeyword

Signature

declare const isObjectKeyword: (ast: AST) => ast is ObjectKeyword

isRefinement

Added in v3.10.0 Source

Signature

declare const isRefinement: (ast: AST) => ast is Refinement<AST>

Signature

declare const isStringKeyword: (ast: AST) => ast is StringKeyword

isSuspend

Added in v3.10.0 Source

Signature

declare const isSuspend: (ast: AST) => ast is Suspend

Signature

declare const isSymbolKeyword: (ast: AST) => ast is SymbolKeyword

Signature

declare const isTemplateLiteral: (ast: AST) => ast is TemplateLiteral

Signature

declare const isTransformation: (ast: AST) => ast is Transformation

isTupleType

Added in v3.10.0 Source

Signature

declare const isTupleType: (ast: AST) => ast is TupleType

isTypeLiteral

Added in v3.10.0 Source

Signature

declare const isTypeLiteral: (ast: AST) => ast is TypeLiteral

Signature

declare const isTypeLiteralTransformation: (ast: TransformationKind) => ast is TypeLiteralTransformation

Signature

declare const isUndefinedKeyword: (ast: AST) => ast is UndefinedKeyword

isUnion

Added in v3.10.0 Source

Signature

declare const isUnion: (ast: AST) => ast is Union

isUniqueSymbol

Added in v3.10.0 Source

Signature

declare const isUniqueSymbol: (ast: AST) => ast is UniqueSymbol

Signature

declare const isUnknownKeyword: (ast: AST) => ast is UnknownKeyword

isVoidKeyword

Added in v3.10.0 Source

Signature

declare const isVoidKeyword: (ast: AST) => ast is VoidKeyword

Model

AnyKeyword

Added in v3.10.0 Source

Signature

declare class AnyKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "AnyKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

AST type

Added in v3.10.0 Source

Signature

type AST = Declaration | Literal | UniqueSymbol | UndefinedKeyword | VoidKeyword | NeverKeyword | UnknownKeyword | AnyKeyword | StringKeyword | NumberKeyword | BooleanKeyword | BigIntKeyword | SymbolKeyword | ObjectKeyword | Enums | TemplateLiteral | Refinement | TupleType | TypeLiteral | Union | Suspend | Transformation

BigIntKeyword

Added in v3.10.0 Source

Signature

declare class BigIntKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "BigIntKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

BooleanKeyword

Added in v3.10.0 Source

Signature

declare class BooleanKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "BooleanKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

Signature

declare class ComposeTransformation {
constructor();
readonly _tag: "ComposeTransformation";
}

Declaration

Added in v3.10.0 Source

Signature

declare class Declaration implements Annotated {
constructor(typeParameters: readonly Array<AST>, decodeUnknown: (...typeParameters: readonly Array<AST>) => (input: unknown, options: ParseOptions, self: Declaration) => Effect<any, ParseIssue, any>, encodeUnknown: (...typeParameters: readonly Array<AST>) => (input: unknown, options: ParseOptions, self: Declaration) => Effect<any, ParseIssue, any>, annotations: Annotations);
readonly _tag: "Declaration";
readonly annotations: Annotations;
readonly decodeUnknown: (...typeParameters: readonly Array<AST>) => (input: unknown, options: ParseOptions, self: Declaration) => Effect<any, ParseIssue, any>;
readonly encodeUnknown: (...typeParameters: readonly Array<AST>) => (input: unknown, options: ParseOptions, self: Declaration) => Effect<any, ParseIssue, any>;
readonly typeParameters: readonly Array<AST>;
toJSON(): object;
toString(): string;
}

Enums

Added in v3.10.0 Source

Signature

declare class Enums implements Annotated {
constructor(enums: readonly Array<readonly [string, string | number]>, annotations: Annotations);
readonly _tag: "Enums";
readonly annotations: Annotations;
readonly enums: readonly Array<readonly [string, string | number]>;
toJSON(): object;
toString(): string;
}

Signature

declare class FinalTransformation {
constructor(decode: (fromA: any, options: ParseOptions, self: Transformation, fromI: any) => Effect<any, ParseIssue, any>, encode: (toI: any, options: ParseOptions, self: Transformation, toA: any) => Effect<any, ParseIssue, any>);
readonly _tag: "FinalTransformation";
readonly decode: (fromA: any, options: ParseOptions, self: Transformation, fromI: any) => Effect<any, ParseIssue, any>;
readonly encode: (toI: any, options: ParseOptions, self: Transformation, toA: any) => Effect<any, ParseIssue, any>;
}

IndexSignature

Added in v3.10.0 Source

Signature

declare class IndexSignature {
constructor(parameter: AST, type: AST, isReadonly: boolean);
readonly isReadonly: boolean;
readonly parameter: Parameter;
readonly type: AST;
toJSON(): object;
toString(): string;
}

Literal

Added in v3.10.0 Source

Signature

declare class Literal implements Annotated {
constructor(literal: LiteralValue, annotations: Annotations);
readonly _tag: "Literal";
readonly annotations: Annotations;
readonly literal: LiteralValue;
toJSON(): object;
toString(): string;
}

LiteralValue type

Added in v3.10.0 Source

Signature

type LiteralValue = string | number | boolean | null | bigint

NeverKeyword

Added in v3.10.0 Source

Signature

declare class NeverKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "NeverKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

NumberKeyword

Added in v3.10.0 Source

Signature

declare class NumberKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "NumberKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

ObjectKeyword

Added in v3.10.0 Source

Signature

declare class ObjectKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "ObjectKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

OptionalType

Added in v3.10.0 Source

Signature

declare class OptionalType extends Type {
constructor(type: AST, isOptional: boolean, annotations: Annotations);
readonly isOptional: boolean;
toJSON(): object;
toString(): string;
}

ParseOptions interface

Added in v3.10.0 Source

Signature

interface ParseOptions {
readonly errors?: "first" | "all";
readonly exact?: boolean;
readonly onExcessProperty?: "error" | "ignore" | "preserve";
readonly propertyOrder?: "none" | "original";
}

Signature

declare class PropertySignature extends OptionalType {
constructor(name: PropertyKey, type: AST, isOptional: boolean, isReadonly: boolean, annotations?: Annotations);
readonly isReadonly: boolean;
readonly name: PropertyKey;
toJSON(): object;
toString(): string;
}

Represents a PropertySignature -> PropertySignature transformation

The semantic of decode is:

  • none() represents the absence of the key/value pair
  • some(value) represents the presence of the key/value pair

The semantic of encode is:

  • none() you don't want to output the key/value pair
  • some(value) you want to output the key/value pair

Signature

declare class PropertySignatureTransformation {
constructor(from: PropertyKey, to: PropertyKey, decode: (o: Option<any>) => Option<any>, encode: (o: Option<any>) => Option<any>);
readonly decode: (o: Option<any>) => Option<any>;
readonly encode: (o: Option<any>) => Option<any>;
readonly from: PropertyKey;
readonly to: PropertyKey;
}

Refinement

Added in v3.10.0 Source

Signature

declare class Refinement<From extends AST = AST> implements Annotated {
constructor<From extends AST = AST>(from: From, filter: (input: any, options: ParseOptions, self: Refinement) => Option<ParseIssue>, annotations: Annotations);
readonly _tag: "Refinement";
readonly annotations: Annotations;
readonly filter: (input: any, options: ParseOptions, self: Refinement) => Option<ParseIssue>;
readonly from: From;
toJSON(): object;
toString(): string;
}

StringKeyword

Added in v3.10.0 Source

Signature

declare class StringKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "StringKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

Suspend

Added in v3.10.0 Source

Signature

declare class Suspend implements Annotated {
constructor(f: () => AST, annotations: Annotations);
readonly _tag: "Suspend";
readonly annotations: Annotations;
readonly f: () => AST;
toJSON(): object;
toString(): string;
}

SymbolKeyword

Added in v3.10.0 Source

Signature

declare class SymbolKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "SymbolKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

Signature

declare class TemplateLiteral implements Annotated {
constructor(head: string, spans: readonly [TemplateLiteralSpan, TemplateLiteralSpan], annotations: Annotations);
readonly _tag: "TemplateLiteral";
readonly annotations: Annotations;
readonly head: string;
readonly spans: readonly [TemplateLiteralSpan, TemplateLiteralSpan];
toJSON(): object;
toString(): string;
}

Signature

declare class TemplateLiteralSpan {
constructor(type: AST, literal: string);
readonly literal: string;
readonly type: TemplateLiteralSpanType;
toJSON(): object;
toString(): string;
}

Transformation

Added in v3.10.0 Source

Signature

declare class Transformation implements Annotated {
constructor(from: AST, to: AST, transformation: TransformationKind, annotations: Annotations);
readonly _tag: "Transformation";
readonly annotations: Annotations;
readonly from: AST;
readonly to: AST;
readonly transformation: TransformationKind;
toJSON(): object;
toString(): string;
}

TransformationKind type

Added in v3.10.0 Source

Signature

type TransformationKind = FinalTransformation | ComposeTransformation | TypeLiteralTransformation

TupleType

Added in v3.10.0 Source

Signature

declare class TupleType implements Annotated {
constructor(elements: readonly Array<OptionalType>, rest: readonly Array<Type>, isReadonly: boolean, annotations: Annotations);
readonly _tag: "TupleType";
readonly annotations: Annotations;
readonly elements: readonly Array<OptionalType>;
readonly isReadonly: boolean;
readonly rest: readonly Array<Type>;
toJSON(): object;
toString(): string;
}

Type

Added in v3.10.0 Source

Signature

declare class Type implements Annotated {
constructor(type: AST, annotations: Annotations);
readonly annotations: Annotations;
readonly type: AST;
toJSON(): object;
toString(): string;
}

TypeLiteral

Added in v3.10.0 Source

Signature

declare class TypeLiteral implements Annotated {
constructor(propertySignatures: readonly Array<PropertySignature>, indexSignatures: readonly Array<IndexSignature>, annotations: Annotations);
readonly _tag: "TypeLiteral";
readonly annotations: Annotations;
readonly indexSignatures: readonly Array<IndexSignature>;
readonly propertySignatures: readonly Array<PropertySignature>;
toJSON(): object;
toString(): string;
}

Signature

declare class TypeLiteralTransformation {
constructor(propertySignatureTransformations: readonly Array<PropertySignatureTransformation>);
readonly _tag: "TypeLiteralTransformation";
readonly propertySignatureTransformations: readonly Array<PropertySignatureTransformation>;
}

Signature

declare class UndefinedKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "UndefinedKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

Union

Added in v3.10.0 Source

Signature

declare class Union<M extends AST = AST> implements Annotated {
readonly _tag: "Union";
readonly annotations: Annotations;
readonly types: readonly [M, M, M];
toJSON(): object;
toString(): string;
static make(types: readonly Array<AST>, annotations?: Annotations): AST;
}

UniqueSymbol

Added in v3.10.0 Source

Signature

declare class UniqueSymbol implements Annotated {
constructor(symbol: symbol, annotations: Annotations);
readonly _tag: "UniqueSymbol";
readonly annotations: Annotations;
readonly symbol: symbol;
toJSON(): object;
toString(): string;
}

UnknownKeyword

Added in v3.10.0 Source

Signature

declare class UnknownKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "UnknownKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

VoidKeyword

Added in v3.10.0 Source

Signature

declare class VoidKeyword implements Annotated {
constructor(annotations: Annotations);
readonly _tag: "VoidKeyword";
readonly annotations: Annotations;
toJSON(): object;
toString(): string;
}

Other

annotations

Added in v3.10.0 Source

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

Any previously existing identifier annotations are deleted.

Signature

declare function annotations(ast: AST, overrides: Annotations): AST

Compiler type

Added in v3.10.0 Source

Signature

type Compiler<A> = (ast: AST, path: ReadonlyArray<PropertyKey>) => A

Signature

declare const defaultParseOption: ParseOptions

encodedAST

Added in v3.10.0 Source

Signature

declare function encodedAST(ast: AST): AST

Signature

declare function encodedBoundAST(ast: AST): AST

getCompiler

Added in v3.10.0 Source

Signature

declare function getCompiler<A>(match: Match<A>): Compiler<A>

Signature

declare function getPropertySignatures(ast: AST): Array<PropertySignature>

Generates a regular expression that captures the pattern defined by the given TemplateLiteral AST.

See

Signature

declare function getTemplateLiteralCapturingRegExp(ast: TemplateLiteral): RegExp

Generates a regular expression from a TemplateLiteral AST node.

See

Signature

declare function getTemplateLiteralRegExp(ast: TemplateLiteral): RegExp

isParameter

Added in v3.10.0 Source

Signature

declare function isParameter(ast: AST): ast is Parameter

keyof

Added in v3.10.0 Source

Equivalent at runtime to the TypeScript type-level keyof operator.

Signature

declare function keyof(ast: AST): AST

Match type

Added in v3.10.0 Source

Signature

type Match<A> = { [K in AST["_tag"]]: (ast: Extract<AST, {
_tag: K;
}>, compile: Compiler<A>, path: ReadonlyArray<PropertyKey>) => A }

Members type

Added in v3.10.0 Source

Signature

type Members<A> = readonly [A, A, ...Array<A>]

mutable

Added in v3.10.0 Source

Creates a new AST with shallow mutability applied to its properties.

Signature

declare function mutable(ast: AST): AST

Signature

declare const null: Literal

omit

Added in v3.10.0 Source

Equivalent at runtime to the built-in TypeScript utility type Omit.

Signature

declare function omit(ast: AST, keys: readonly Array<PropertyKey>): TypeLiteral | Transformation

Parameter type

Added in v3.10.0 Source

Signature

type Parameter = StringKeyword | SymbolKeyword | TemplateLiteral | Refinement<Parameter>

partial

Added in v3.10.0 Source

Equivalent at runtime to the built-in TypeScript utility type Partial.

Signature

declare function partial(ast: AST, options?: {
readonly exact: true;
}): AST

pick

Added in v3.10.0 Source

Equivalent at runtime to the built-in TypeScript utility type Pick.

Signature

declare function pick(ast: AST, keys: readonly Array<PropertyKey>): TypeLiteral | Transformation

required

Added in v3.10.0 Source

Equivalent at runtime to the built-in TypeScript utility type Required.

Signature

declare function required(ast: AST): AST

typeAST

Added in v3.10.0 Source

Signature

declare function typeAST(ast: AST): AST

Schema Id

Signature

declare const ParseJsonSchemaId: unique symbol