On this page

Class ParsingContext

State associated parsing at a given point in an expression tree.

Index

Constructors

Properties

expectedType: Type
key: string
path: number[]
scope: Scope

Methods

  • Returns null if t is a subtype of expected; otherwise returns an error message and also pushes it to this.errors.

    Parameters

    • expected: Type

      The expected type

    • t: Type

      The actual type

    Returns string

    null if t is a subtype of expected; otherwise returns an error message

  • Returns a copy of this context suitable for parsing the subexpression at index index, optionally appending to 'let' binding map.

    Note that errors property, intended for collecting errors while parsing, is copied by reference rather than cloned.

    Parameters

    • index: number
    • OptionalexpectedType: Type | null
    • Optionalbindings: [string, Expression][]

    Returns ParsingContext

  • Push a parsing (or type checking) error into the this.errors

    Parameters

    • error: string

      The message

    • ...keys: number[]

      Optionally specify the source of the error at a child of the current expression at this.key.

    Returns void

  • Parameters

    • expr: unknown

      the JSON expression to parse

    • Optionalindex: number

      the optional argument index if this expression is an argument of a parent expression that's being parsed

    • OptionalexpectedType: Type | null
    • Optionalbindings: [string, Expression][]
    • Optionaloptions: { typeAnnotation?: "assert" | "coerce" | "omit" }

    Returns Expression

Was this helpful?
SDK JS
Reference
ParsingContext