effect-io-ai

Package: effect
Module: SchemaAST

SchemaAST.Arrays

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

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

Signature

declare class Arrays { constructor(
    isMutable: boolean,
    elements: ReadonlyArray<AST>,
    rest: ReadonlyArray<AST>,
    annotations?: Schema.Annotations.Annotations,
    checks?: Checks,
    encoding?: Encoding,
    context?: Context,
    encodingChecks?: Checks
  ) }

Source

Since v4.0.0