type-alias / @typed/router/Path

PathParams

Extracts decoded path-parameter fields from a route string.

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

Import

import type { PathParams } from "@typed/router/Path";

Signatures

export type PathParams<P extends string> = ParseAsts<P> extends infer Asts ? [
    Asts
] extends [
    never
] ? never : Asts extends ReadonlyArray<PathAst> ? ToReadonlyRecord<GetPathParams<Asts>> : never : never;

Why

Handlers can distinguish path values from query values without manual record projection.

Ownership and lifetime

TypeScript computes PathParams from the route literal or AST tuple supplied to it; the alias is erased and retains no runtime data.

Source