Hyperlinkv0.8.0-beta.28

SchemaAST

SchemaAST.Baseclasseffect/SchemaAST.ts:606
Base

Represents 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.

export abstract class Base {
  readonly [TypeId] = TypeId
  abstract readonly _tag: string
  readonly annotations: Schema.Annotations.Annotations | undefined
  readonly checks: Checks | undefined
  readonly encoding: Encoding | undefined
  readonly context: Context | undefined

  constructor(
    annotations: Schema.Annotations.Annotations | undefined = undefined,
    checks: Checks | undefined = undefined,
    encoding: Encoding | undefined = undefined,
    context: Context | undefined = undefined
  ) {
    this.annotations = annotations
    this.checks = checks
    this.encoding = encoding
    this.context = context
  }
  toString() {
    return `<${this._tag}>`
  }
}
Referenced by 21 symbols