SymbolProvides the singleton Symbol AST instance.
When to use
Use to reuse the singleton AST node for schemas that match any JavaScript symbol value.
Gotchas
String-based codecs can encode only symbols registered with Symbol.for,
because the implementation uses Symbol.keyFor.
export const const symbol: Symbolconst 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;
}
Provides the singleton
Symbol
AST instance.
When to use
Use to reuse the singleton AST node for schemas that match any JavaScript
symbol value.
Gotchas
String-based codecs can encode only symbols registered with Symbol.for,
because the implementation uses Symbol.keyFor.
symbol = new constructor Symbol(annotations?: Schema.Annotations.Annotations | undefined, checks?: Checks | undefined, encoding?: Encoding | undefined, context?: Context | undefined): 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.
Symbol()