Package: effect
Module: SchemaAST
AST node for array-like types — both tuples and arrays.
When to use
Use when constructing or inspecting AST nodes for tuple or array-like schemas, including rest elements.
Details
elements — positional element types (tuple elements). An element is
optional if its Context.isOptional is true.rest — the rest/variadic element types. When non-empty, the first
entry is the “spread” type (e.g. ...Array<string>), and subsequent
entries are trailing positional elements after the spread.isMutable — whether the resulting array is readonly (false) or
mutable (true).Gotchas
Construction enforces TypeScript ordering rules: a required element cannot follow an optional one, and an optional element cannot follow a rest element.
Example (Inspecting a tuple AST)
import { Schema, SchemaAST } from "effect"
const schema = Schema.Tuple([Schema.String, Schema.Number])
const ast = schema.ast
if (SchemaAST.isArrays(ast)) {
console.log(ast.elements.length) // 2
console.log(ast.rest.length) // 0
}
See
isArraysObjectsSignature
declare class Arrays { constructor(
isMutable: boolean,
elements: ReadonlyArray<AST>,
rest: ReadonlyArray<AST>,
annotations?: Schema.Annotations.Annotations,
checks?: Checks,
encoding?: Encoding,
context?: Context,
encodingChecks?: Checks
) }
Since v4.0.0