function / @typed/router

make

Constructs a Route from a Route AST and lazily memoizes its path and schemas.

Package version
1.0.0-beta.7
Category
Route construction
Since
1.0.0

Import

import { make } from "@typed/router";

Signatures

export declare function make<const P extends string, S extends Schema.Codec<any, Path.Params<P>, any, any> = Schema.Codec<Path.Params<P>>>(ast: AST.RouteAst): Route<P, S>;

Why

Advanced builders can preserve the same invariants as built-in route constructors.

Ownership and lifetime

make constructs its Route immediately. The Route retains the supplied AST or route values and lazily memoizes derived paths and Codecs; Codec services are required only when decoding or encoding runs.

Examples

import * as Router from "@typed/router"
import { literal, path } from "@typed/router/AST"

const Account = Router.make<"/account">(path(literal("account")))

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source