variable / @typed/router

ParamWithSchema

Constructs a named path parameter decoded by an Effect Schema Codec.

Package version
1.0.0-beta.13
Category
Parameter codecs
Since
1.0.0

Import

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

Signatures

export declare const ParamWithSchema: <const P extends string, S extends Schema.Codec<any, string, any, any> = Schema.Codec<string>>(paramName: P, schema: S) => Route<`/:${P}`, Schema.Codec<{
    readonly [K in P]: S["Type"];
}, Path.Params<`/:${P}`>, S["DecodingServices"], S["EncodingServices"]>>;

Why

Routes can expose domain values while retaining encoded string matching and schema services.

Ownership and lifetime

ParamWithSchema 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.

Other public imports

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

Source