NameableBuilder
Defined in: src/schema/index.ts:376
Builder state right after appending an element: chain the next
element directly, or name this one with .as() first.
Extends
Section titled “Extends”PatternBuilder<readonly [...TPattern,TElement],$>
Type Parameters
Section titled “Type Parameters”TPattern
Section titled “TPattern”TPattern extends readonly PatternSchema[]
$
$ extends BindingScope
TElement
Section titled “TElement”TElement extends PatternSchemaBase
Properties
Section titled “Properties”~pattern
Section titled “~pattern”
readonly~pattern: readonly [TPattern,TElement]
Defined in: src/schema/index.ts:261
Inherited from
Section titled “Inherited from”~resultType
Section titled “~resultType”
readonly~resultType:undefined
Defined in: src/schema/index.ts:262
Inherited from
Section titled “Inherited from”
readonly~eval:undefined
Defined in: src/schema/index.ts:263
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”number()
Section titled “number()”number():
NameableBuilder<readonly [TPattern,TElement],$,NumberSchema>
Defined in: src/schema/index.ts:266
Append a number literal element
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, NumberSchema>
Inherited from
Section titled “Inherited from”string()
Section titled “string()”string<
TQuotes>(quotes):NameableBuilder<readonly [TPattern,TElement],$,StringSchema<TQuotes>>
Defined in: src/schema/index.ts:270
Append a string literal element, e.g. p.string(['"', "'"]) —
escapes are processed
Type Parameters
Section titled “Type Parameters”TQuotes
Section titled “TQuotes”TQuotes extends readonly string[]
Parameters
Section titled “Parameters”quotes
Section titled “quotes”TQuotes
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, StringSchema<TQuotes>>
Inherited from
Section titled “Inherited from”ident()
Section titled “ident()”ident():
NameableBuilder<readonly [TPattern,TElement],$,IdentSchema>
Defined in: src/schema/index.ts:275
Append an identifier element (single segment, no dots)
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, IdentSchema>
Inherited from
Section titled “Inherited from”path()
Section titled “path()”path():
NameableBuilder<readonly [TPattern,TElement],$,PathSchema>
Defined in: src/schema/index.ts:280
Append a member-access path element: matches ident(.ident)*
(e.g. values.password), type resolved by walking the schema.
Whitespace around the dots is not allowed.
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, PathSchema>
Inherited from
Section titled “Inherited from”constVal()
Section titled “constVal()”constVal<
TValues>(…values):NameableBuilder<readonly [TPattern,TElement],$,ConstSchema<TValues>>
Defined in: src/schema/index.ts:301
Append a constant element — one or more values as an ORDERED
alternation (first match wins). IDENTIFIER-LIKE values
(constVal("null"), constVal("and")) match only as a WHOLE
identifier — nullable or andy never match (word-boundary rule;
pinned in design-claims); other values ("+", "==") match as raw
text, per member. Keyword literals are ordinary const-pattern nodes;
name the element to receive the MATCHED text in eval:
Type Parameters
Section titled “Type Parameters”TValues
Section titled “TValues”TValues extends readonly [string, string]
Parameters
Section titled “Parameters”values
Section titled “values”…TValues
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ConstSchema<TValues>>
Example
Section titled “Example”const booleanLit = defineNode({ name: "bool", precedence: 5, pattern: (p) => p.constVal("true", "false").as("word") .result("boolean") .eval(({ word }) => word() === "true"),});Inherited from
Section titled “Inherited from”operand()
Section titled “operand()”Call Signature
Section titled “Call Signature”operand():
NameableBuilder<readonly [TPattern,TElement],$,ExprSchema<undefined,"operand">>
Defined in: src/schema/index.ts:316
Append a TIGHTER-LEVEL expression element.
Parses at the next-higher grammar level, avoiding left-recursion.
A pattern whose final operand is operand() makes its level
LEFT-associative (the engine folds repetitions: a-b-c → (a-b)-c).
Constraint forms: operand(“number”), operand(“string | number”), operand(“left”) (a binding reference — not valid at position 0, where no earlier operand exists), operand().
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ExprSchema<undefined, "operand">>
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”operand<
C>(constraint):NameableBuilder<readonly [TPattern,TElement],$,ExprSchema<C,"operand">>
Defined in: src/schema/index.ts:317
Type Parameters
Section titled “Type Parameters”C extends string
Parameters
Section titled “Parameters”constraint
Section titled “constraint”[C] extends [" anyOrNever"] ? C : C extends OptionalPropertyDefinition ? "Optional definitions like 'string?' are only valid as properties in an object or tuple" : isDefaultable<C, $, bindThis<C>> extends true ? "Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple" : validateInnerDefinition<C, $, bindThis<C>>
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ExprSchema<C, "operand">>
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”operand<
B>(constraint):NameableBuilder<readonly [TPattern,TElement],$,ExprSchema<OverlapsRef<B>,"operand">>
Defined in: src/schema/index.ts:320
Type Parameters
Section titled “Type Parameters”B extends string
Parameters
Section titled “Parameters”constraint
Section titled “constraint”OverlapsRef<ValidateOverlapsTarget<B, $>>
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ExprSchema<OverlapsRef<B>, "operand">>
Inherited from
Section titled “Inherited from”rest()
Section titled “rest()”Call Signature
Section titled “Call Signature”rest():
NameableBuilder<readonly [TPattern,TElement],$,ExprSchema<undefined,"rest">>
Defined in: src/schema/index.ts:333
Append a CURRENT-LEVEL expression element.
Parses at the same level. A pattern whose final operand is rest()
makes its level RIGHT-associative (a ^ b ^ c → a ^ (b ^ c)).
Constraint forms: rest(“number”), rest(“left”), rest(“left | null”), rest(overlapping(“left”)), rest().
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ExprSchema<undefined, "rest">>
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”rest<
C>(constraint):NameableBuilder<readonly [TPattern,TElement],$,ExprSchema<C,"rest">>
Defined in: src/schema/index.ts:334
Type Parameters
Section titled “Type Parameters”C extends string
Parameters
Section titled “Parameters”constraint
Section titled “constraint”[C] extends [" anyOrNever"] ? C : C extends OptionalPropertyDefinition ? "Optional definitions like 'string?' are only valid as properties in an object or tuple" : isDefaultable<C, $, bindThis<C>> extends true ? "Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple" : validateInnerDefinition<C, $, bindThis<C>>
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ExprSchema<C, "rest">>
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”rest<
B>(constraint):NameableBuilder<readonly [TPattern,TElement],$,ExprSchema<OverlapsRef<B>,"rest">>
Defined in: src/schema/index.ts:337
Type Parameters
Section titled “Type Parameters”B extends string
Parameters
Section titled “Parameters”constraint
Section titled “constraint”OverlapsRef<ValidateOverlapsTarget<B, $>>
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ExprSchema<OverlapsRef<B>, "rest">>
Inherited from
Section titled “Inherited from”expr()
Section titled “expr()”Call Signature
Section titled “Call Signature”expr():
NameableBuilder<readonly [TPattern,TElement],$,ExprSchema<undefined,"expr">>
Defined in: src/schema/index.ts:349
Append a FULL expression element.
Resets to the full grammar (precedence 0). Only for DELIMITED contexts — every expr() must be followed by at least one constVal in the same pattern (parentheses’ “)”, ternary’s “:”), otherwise it would swallow looser operators and break precedence.
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ExprSchema<undefined, "expr">>
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”expr<
C>(constraint):NameableBuilder<readonly [TPattern,TElement],$,ExprSchema<C,"expr">>
Defined in: src/schema/index.ts:350
Type Parameters
Section titled “Type Parameters”C extends string
Parameters
Section titled “Parameters”constraint
Section titled “constraint”[C] extends [" anyOrNever"] ? C : C extends OptionalPropertyDefinition ? "Optional definitions like 'string?' are only valid as properties in an object or tuple" : isDefaultable<C, $, bindThis<C>> extends true ? "Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple" : validateInnerDefinition<C, $, bindThis<C>>
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ExprSchema<C, "expr">>
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”expr<
B>(constraint):NameableBuilder<readonly [TPattern,TElement],$,ExprSchema<OverlapsRef<B>,"expr">>
Defined in: src/schema/index.ts:353
Type Parameters
Section titled “Type Parameters”B extends string
Parameters
Section titled “Parameters”constraint
Section titled “constraint”OverlapsRef<ValidateOverlapsTarget<B, $>>
Returns
Section titled “Returns”NameableBuilder<readonly [TPattern, TElement], $, ExprSchema<OverlapsRef<B>, "expr">>
Inherited from
Section titled “Inherited from”result()
Section titled “result()”result<
R>(def):ResultedBuilder<readonly [TPattern,TElement],R>
Defined in: src/schema/index.ts:369
Declare the node’s result type (trailing — after the last element):
- a binding name (“then”) — derived per-parse from that operand
- an arktype def (“boolean”, { min: “number”, max: “number” }) — the node mints a type; defs may EMBED binding references (“then | null”), resolved per-parse
Validated by arktype with the chain’s bindings in scope. Required for every node that CONSTRUCTS a result; only a single-element passthrough pattern omits it. (The “~resolved” key is reserved — enforced at construction.)
Type Parameters
Section titled “Type Parameters”R extends ResultSpec
Parameters
Section titled “Parameters”[R] extends [" anyOrNever"] ? R : R extends OptionalPropertyDefinition ? "Optional definitions like 'string?' are only valid as properties in an object or tuple" : isDefaultable<R, $, bindThis<R>> extends true ? "Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple" : validateInnerDefinition<R, $, bindThis<R>>
Returns
Section titled “Returns”ResultedBuilder<readonly [TPattern, TElement], R>
Inherited from
Section titled “Inherited from”as<
TName>(name):PatternBuilder<readonly [TPattern,NamedSchema<TElement,TName>],ScopeAdd<TElement,TName,$>>
Defined in: src/schema/index.ts:384
Name the element just appended: it becomes a binding — a field on the AST node, a typed thunk in eval’s parameter, and (for non-const elements) a scope alias for later constraints and the result def.
Type Parameters
Section titled “Type Parameters”TName extends string
Parameters
Section titled “Parameters”ValidateBindingName<TName, TPattern>
Returns
Section titled “Returns”PatternBuilder<readonly [TPattern, NamedSchema<TElement, TName>], ScopeAdd<TElement, TName, $>>