DeclarationAST node for user-defined opaque types with custom parsing logic.
When to use
Use when you need a custom schema AST node because none of the built-in nodes fit.
Details
typeParameters— inner schemas this declaration is parameterized over (e.g. the element type for a custom collection).run— factory that receivestypeParametersand returns a parser that validates or transforms raw input.
export class class Declarationclass Declaration {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node for user-defined opaque types with custom parsing logic.
When to use
Use when you need a custom schema AST node because none of the built-in
nodes fit.
Details
typeParameters — inner schemas this declaration is parameterized over
(e.g. the element type for a custom collection).
run — factory that receives typeParameters and returns a parser that
validates or transforms raw input.
Declaration extends class BaseRepresents the abstract base class for all
AST
node variants.
Details
Every AST node extends Base and inherits these fields:
annotations — user-supplied metadata (identifier, title, description,
arbitrary keys).
checks — optional
Checks
for post-type-match validation.
encoding — optional
Encoding
chain for type ↔ wire
transformations.
context — optional
Context
for per-property metadata.
Subclasses add a _tag discriminant and variant-specific data.
Base {
readonly Declaration._tag: "Declaration"_tag = "Declaration"
readonly Declaration.typeParameters: ReadonlyArray<AST>typeParameters: interface ReadonlyArray<T>ReadonlyArray<type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST>
readonly Declaration.run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>run: (
typeParameters: ReadonlyArray<AST>typeParameters: interface ReadonlyArray<T>ReadonlyArray<type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST>
) => (input: unknowninput: unknown, self: Declaration(parameter) self: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
self: class Declarationclass Declaration {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node for user-defined opaque types with custom parsing logic.
When to use
Use when you need a custom schema AST node because none of the built-in
nodes fit.
Details
typeParameters — inner schemas this declaration is parameterized over
(e.g. the element type for a custom collection).
run — factory that receives typeParameters and returns a parser that
validates or transforms raw input.
Declaration, options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options: ParseOptions) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<any, import SchemaIssueSchemaIssue.type Issue =
| SchemaIssue.Leaf
| SchemaIssue.Filter
| SchemaIssue.Encoding
| SchemaIssue.Pointer
| SchemaIssue.Composite
| SchemaIssue.AnyOf
The root discriminated union of all validation error nodes.
When to use
Use when typing the error channel in Effect<A, Issue, R> results from
schema parsing, or when writing custom formatters or issue-tree walkers.
Details
Every node has a _tag field for pattern-matching. The union includes both
terminal
Leaf
types and composite types that wrap inner issues:
Filter
,
Encoding
,
Pointer
,
Composite
,
AnyOf
. All Issue instances have a toString() that delegates to
the default formatter, so String(issue) produces a human-readable message.
Issue, any>
readonly Declaration.encodingChecks: Checks | undefinedencodingChecks: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks | undefined
constructor(
typeParameters: ReadonlyArray<AST>typeParameters: interface ReadonlyArray<T>ReadonlyArray<type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST>,
run: (
typeParameters: ReadonlyArray<AST>
) => (
input: unknown,
self: Declaration,
options: ParseOptions
) => Effect.Effect<any, SchemaIssue.Issue, any>
run: (
typeParameters: ReadonlyArray<AST>typeParameters: interface ReadonlyArray<T>ReadonlyArray<type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST>
) => (input: unknowninput: unknown, self: Declaration(parameter) self: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
self: class Declarationclass Declaration {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node for user-defined opaque types with custom parsing logic.
When to use
Use when you need a custom schema AST node because none of the built-in
nodes fit.
Details
typeParameters — inner schemas this declaration is parameterized over
(e.g. the element type for a custom collection).
run — factory that receives typeParameters and returns a parser that
validates or transforms raw input.
Declaration, options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options: ParseOptions) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<any, import SchemaIssueSchemaIssue.type Issue =
| SchemaIssue.Leaf
| SchemaIssue.Filter
| SchemaIssue.Encoding
| SchemaIssue.Pointer
| SchemaIssue.Composite
| SchemaIssue.AnyOf
The root discriminated union of all validation error nodes.
When to use
Use when typing the error channel in Effect<A, Issue, R> results from
schema parsing, or when writing custom formatters or issue-tree walkers.
Details
Every node has a _tag field for pattern-matching. The union includes both
terminal
Leaf
types and composite types that wrap inner issues:
Filter
,
Encoding
,
Pointer
,
Composite
,
AnyOf
. All Issue instances have a toString() that delegates to
the default formatter, so String(issue) produces a human-readable message.
Issue, any>,
annotations: anyannotations?: import SchemaSchema.declareAnnotations.type Schema.Annotations.Annotations = /*unresolved*/ anyAnnotations,
checks: Checkschecks?: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks,
encoding: Encodingencoding?: type Encoding = readonly [Link, ...Link[]]A non-empty chain of
Link
values representing the transformation
steps between a schema's decoded (type) form and its encoded (wire) form.
Details
Stored on
Base.encoding
. When undefined, the node has no
encoding transformation (type and encoded forms are identical).
Encoding,
context: Contextcontext?: class Contextclass Context {
isOptional: boolean;
isMutable: boolean;
defaultValue: Encoding | undefined;
annotations: Schema.Annotations.Key<unknown> | undefined;
}
Represents per-property metadata attached to AST nodes via
Base.context
.
Details
Tracks whether a property key is optional, mutable, has a constructor
default, or carries key-level annotations. Typically set by helpers like
optionalKey
and Schema.mutableKey.
isOptional — the property key may be absent from the input.
isMutable — the property is readonly when false.
defaultValue — an
Encoding
applied during construction to
supply missing values.
annotations — key-level annotations (e.g. description of the key
itself).
Context,
encodingChecks: ChecksencodingChecks?: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks
) {
super(annotations: anyannotations, checks: Checkschecks, encoding: Encodingencoding, context: Contextcontext)
this.Declaration.typeParameters: ReadonlyArray<AST>typeParameters = typeParameters: ReadonlyArray<AST>typeParameters
this.Declaration.run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>run = run: (
typeParameters: ReadonlyArray<AST>
) => (
input: unknown,
self: Declaration,
options: ParseOptions
) => Effect.Effect<any, SchemaIssue.Issue, any>
run
this.Declaration.encodingChecks: Checks | undefinedencodingChecks = encodingChecks: ChecksencodingChecks
}
/** @internal */
Declaration.getParser(): SchemaParser.ParsergetParser(): import SchemaParserSchemaParser.Parser {
const const run: (
input: unknown,
self: Declaration,
options: ParseOptions
) => Effect.Effect<any, SchemaIssue.Issue, any>
run = this.Declaration.run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>run(this.Declaration.typeParameters: ReadonlyArray<AST>typeParameters)
return (oinput: Option.Option<unknown>oinput, options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options) => {
if (import OptionOption.isNone(oinput: Option.Option<unknown>oinput)) return import EffectEffect.succeedNone
return import EffectEffect.mapEager(const run: (
input: unknown,
self: Declaration,
options: ParseOptions
) => Effect.Effect<any, SchemaIssue.Issue, any>
run(oinput: Option.Some<unknown>(parameter) oinput: {
_tag: "Some";
_op: "Some";
value: A;
valueOrUndefined: A;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
oinput.value, this, options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options), import OptionOption.some)
}
}
private Declaration._rebuild(recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined): Declaration_rebuild(recur: (ast: AST) => ASTrecur: (ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) => type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST, checks: Checks | undefinedchecks: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks | undefined, encodingChecks: Checks | undefinedencodingChecks: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks | undefined) {
const const tps: ReadonlyArray<AST>tps = function mapOrSame<AST>(as: Arr.NonEmptyReadonlyArray<AST>, f: (a: AST) => AST): Arr.NonEmptyReadonlyArray<AST> (+1 overload)Maps over the array but will return the original array if no changes occur.
mapOrSame(this.Declaration.typeParameters: ReadonlyArray<AST>typeParameters, recur: (ast: AST) => ASTrecur)
return const tps: ReadonlyArray<AST>tps === this.Declaration.typeParameters: ReadonlyArray<AST>typeParameters && checks: Checks | undefinedchecks === this.Base.checks: Checks | undefinedchecks && encodingChecks: Checks | undefinedencodingChecks === this.Declaration.encodingChecks: Checks | undefinedencodingChecks ?
this :
new constructor Declaration(typeParameters: ReadonlyArray<AST>, run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>, annotations?: Schema.Annotations.Annotations, checks?: Checks, encoding?: Encoding, context?: Context, encodingChecks?: Checks): DeclarationAST node for user-defined opaque types with custom parsing logic.
When to use
Use when you need a custom schema AST node because none of the built-in
nodes fit.
Details
typeParameters — inner schemas this declaration is parameterized over
(e.g. the element type for a custom collection).
run — factory that receives typeParameters and returns a parser that
validates or transforms raw input.
Declaration(const tps: ReadonlyArray<AST>tps, this.Declaration.run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>run, this.Base.annotations: anyannotations, checks: Checks | undefinedchecks, var undefinedundefined, this.Base.context: Context | undefinedcontext, encodingChecks: Checks | undefinedencodingChecks)
}
/** @internal */
Declaration.recur(recur: (ast: AST) => AST): Declarationrecur(recur: (ast: AST) => ASTrecur: (ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) => type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) {
return this.Declaration._rebuild(recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined): Declaration_rebuild(recur: (ast: AST) => ASTrecur, this.Base.checks: Checks | undefinedchecks, this.Declaration.encodingChecks: Checks | undefinedencodingChecks)
}
/** @internal */
Declaration.flip(recur: (ast: AST) => AST): Declarationflip(recur: (ast: AST) => ASTrecur: (ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) => type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) {
return this.Declaration._rebuild(recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined): Declaration_rebuild(recur: (ast: AST) => ASTrecur, this.Declaration.encodingChecks: Checks | undefinedencodingChecks, this.Base.checks: Checks | undefinedchecks)
}
/** @internal */
Declaration.getExpected(): stringgetExpected(): string {
const const expected: anyexpected = this.Base.annotations: anyannotations?.expected
if (typeof const expected: anyexpected === "string") return const expected: stringexpected
return "<Declaration>"
}
}