type-alias / @typed/router/AST

PathAst

The union of path, parameter, wildcard, slash, and query AST nodes.

Package version
1.0.0-beta.7
Category
Path syntax
Since
1.0.0

Import

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

Signatures

export type PathAst = PathAst.Literal | PathAst.Parameter | PathAst.Slash | PathAst.Wildcard | PathAst.QueryParams;
export declare namespace PathAst {
    type Literal = {
        type: "literal";
        value: string;
    };
    type Parameter = {
        type: "parameter";
        name: string;
        optional?: boolean;
        regex?: string;
    };
    type Wildcard = {
        type: "wildcard";
    };
    type Slash = {
        type: "slash";
    };
    type QueryParams = {
        type: "query-params";
        value: ReadonlyArray<PathAst.QueryParam>;
    };
    type QueryParam = {
        type: "query-param";
        name: string;
        value: PathAst;
    };
}

Why

One explicit syntax tree feeds formatting, schema derivation, and matcher compilation.

Ownership and lifetime

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

Members

Source