type-alias / @typed/router/AST

PathAst.Parameter

A named path parameter with optionality and an optional regular expression.

Package version
1.0.0-beta.7
Category
Path syntax
Since
1.0.0
Member of
PathAst

Import

import { PathAst } from "@typed/router/AST";

Access PathAst.Parameter through the imported PathAst export. Its declaration below describes the member.

Signatures

type Parameter = {
    type: "parameter";
    name: string;
    optional?: boolean;
    regex?: string;
};

Why

Parameter constraints stay available to both matcher registration and schema derivation.

Ownership and lifetime

Parameter describes plain readonly AST data. Routes and Matchers retain the concrete nodes they receive by reference; the type itself owns no resource.

Property: name

Name assigned to the decoded parameter field.

Property: name: Why

Duplicate decoded names can be rejected before matcher execution.

Property: name: Ownership and lifetime

The node retains the immutable name; decoded values are owned by the selected route’s params RefSubject, not by this AST.

Property: optional

Whether this segment may be absent.

Property: optional: Why

Optionality controls both matcher syntax and optional schema fields.

Property: optional: Ownership and lifetime

The flag is immutable metadata retained with the node and creates no fallback value itself.

Property: regex

Optional source pattern constraining the captured segment.

Property: regex: Why

Constrained and generic parameters can compile to distinct matcher path shapes.

Property: regex: Ownership and lifetime

The node retains the pattern string. Matcher compilation interprets it later and can surface invalid registration syntax as RouteDecodeError.

Property: type

Discriminates a named parameter node.

Property: type: Why

Schema derivation and matcher compilation must recognize captured segments identically.

Property: type: Ownership and lifetime

The literal tag remains on the plain node for its lifetime and owns no resource.

Source