@buntal/core - Types

ExtractRouteParams

A utility type that extracts route parameters from a URL path string, converting path segments like ':id' into typed properties.

Source

View source on GitHub

Type Definition

type ExtractRouteParams<T extends string> =
  T extends `${string}:${infer Param}/${infer Rest}`
    ? { [K in Param]: string } & ExtractRouteParams<Rest>
    : T extends `${string}:${infer Param}`
    ? { [K in Param]: string }
    : {};

Parameters

ParameterTypeRequiredDefaultDescription
Tstring-The URL path string template containing parameter placeholders like ':id', ':name', etc.

Last modified: 2025-06-10

Content-Length: 0