SymbolAST node matching any symbol value.
When to use
Use when you need the AST node class for schemas that match any JavaScript symbol value.
Details
When serialized to a string-based codec, symbols are converted via
Symbol.keyFor and must be registered with Symbol.for.
export class class Symbolclass Symbol {
_tag: 'Symbol';
getParser: () => SchemaParser.Parser;
matchKey: (s: symbol, options: ParseOptions) => symbol | undefined;
toCodecStringTree: () => AST;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node matching any symbol value.
When to use
Use when you need the AST node class for schemas that match any JavaScript
symbol value.
Details
When serialized to a string-based codec, symbols are converted via
Symbol.keyFor and must be registered with Symbol.for.
Symbol 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 Symbol._tag: "Symbol"_tag = "Symbol"
/** @internal */
Symbol.getParser(): SchemaParser.ParsergetParser() {
return function fromRefinement<T>(
ast: AST,
refinement: (input: unknown) => input is T
): SchemaParser.Parser
fromRefinement(this, import PredicatePredicate.isSymbol)
}
/** @internal */
Symbol.matchKey(s: symbol, options: ParseOptions): symbol | undefinedmatchKey(s: symbols: symbol, 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): symbol | undefined {
return function applyTemplateLiteralPartChecks<
A
>(
ast: AST,
value: A,
options: ParseOptions
): A | undefined
applyTemplateLiteralPartChecks(this, s: symbols, 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)
}
/** @internal */
Symbol.toCodecStringTree(): ASTtoCodecStringTree(): 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 function replaceEncoding<A extends AST>(
ast: A,
encoding: Encoding | undefined
): A
replaceEncoding(this, [const symbolToString: Linkconst symbolToString: {
to: AST;
transformation: SchemaTransformation.Transformation<any, any, any, any> | SchemaTransformation.Middleware<any, any, any, any, any, any>;
}
to distinguish between Symbol and String, we need to add a check to the string keyword
symbolToString])
}
/** @internal */
Symbol.getExpected(): stringgetExpected(): string {
return "symbol"
}
}