UniqueSymbolAST node matching a specific unique symbol value.
Details
Parsing succeeds only when the input is reference-equal to the stored
symbol.
export class class UniqueSymbolclass UniqueSymbol {
_tag: 'UniqueSymbol';
symbol: symbol;
getParser: () => SchemaParser.Parser;
toCodecStringTree: () => AST;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node matching a specific unique symbol value.
Details
Parsing succeeds only when the input is reference-equal to the stored
symbol.
UniqueSymbol 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 UniqueSymbol._tag: "UniqueSymbol"_tag = "UniqueSymbol"
readonly UniqueSymbol.symbol: symbolsymbol: symbol
constructor(
symbol: symbolsymbol: symbol,
annotations: anyannotations?: import SchemaSchema.declareAnnotations.type Schema.Annotations.Annotations = /*unresolved*/ anyAnnotations,
checks: Checkschecks?: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks,
encoding: Encodingencoding?: type Encoding = readonly [Link, ...Link[]]A non-empty chain of
Link
values representing the transformation
steps between a schema's decoded (type) form and its encoded (wire) form.
Details
Stored on
Base.encoding
. When undefined, the node has no
encoding transformation (type and encoded forms are identical).
Encoding,
context: Contextcontext?: class Contextclass Context {
isOptional: boolean;
isMutable: boolean;
defaultValue: Encoding | undefined;
annotations: Schema.Annotations.Key<unknown> | undefined;
}
Represents per-property metadata attached to AST nodes via
Base.context
.
Details
Tracks whether a property key is optional, mutable, has a constructor
default, or carries key-level annotations. Typically set by helpers like
optionalKey
and Schema.mutableKey.
isOptional — the property key may be absent from the input.
isMutable — the property is readonly when false.
defaultValue — an
Encoding
applied during construction to
supply missing values.
annotations — key-level annotations (e.g. description of the key
itself).
Context
) {
super(annotations: anyannotations, checks: Checkschecks, encoding: Encodingencoding, context: Contextcontext)
this.UniqueSymbol.symbol: symbolsymbol = symbol: symbolsymbol
}
/** @internal */
UniqueSymbol.getParser(): SchemaParser.ParsergetParser() {
return function fromConst<T>(
ast: AST,
value: T
): SchemaParser.Parser
fromConst(this, this.UniqueSymbol.symbol: symbolsymbol)
}
/** @internal */
UniqueSymbol.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 */
UniqueSymbol.getExpected(): stringgetExpected(): string {
return module globalThisglobalThis.var String: StringConstructor
;(value?: any) => string
Allows manipulation and formatting of text strings and determination and location of substrings within strings.
String(this.UniqueSymbol.symbol: symbolsymbol)
}
}