Type alias Params<S>

Params<S>: S extends `${string}:${infer P}`
    ? (P extends `${Left<P>}${infer I}`
        ? Router.Params<I>
        : never) & (Left<P> extends `${infer I}?`
        ? {
            [K in I]?: string
        }
        : {
            [K in Left<P>]: string
        })
    : {}

Type helper representing the (optional) Params of a Route path. By extracting string literals starting with a colon (and optionally ending on a question mark), a union type of a key/value pair for each parameter is created.

Type Parameters

  • S

    The Route path string type.

Example

Extract Params from 'item/:id/field/:name?':

import { type Router } from '@sgrud/shell';

const params: Router.Params<'item/:id/field/:name?'>;
// { id: string; name?: string; }

Generated using TypeDoc