UNPKG

663 BTypeScriptView Raw
1
2import { Equal } from "./types/utils.js";
3import { Pages } from "./types/register.js";
4
5//#region lib/href.d.ts
6type Args = { [K in keyof Pages]: ToArgs<Pages[K]["params"]> };
7type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [Params];
8/**
9 Returns a resolved URL path for the specified route.
10
11 ```tsx
12 const h = href("/:lang?/about", { lang: "en" })
13 // -> `/en/about`
14
15 <Link to={href("/products/:id", { id: "abc123" })} />
16 ```
17 */
18declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
19//#endregion
20export { href };
\No newline at end of file