diff --git a/packages/wouter-preact/types/index.d.ts b/packages/wouter-preact/types/index.d.ts index aa5030b..21252a4 100644 --- a/packages/wouter-preact/types/index.d.ts +++ b/packages/wouter-preact/types/index.d.ts @@ -21,7 +21,7 @@ import { BrowserSearchHook, } from "./use-browser-location.js"; -import { RouterObject, RouterOptions } from "./router.js"; +import { RouterObject, RouterOptions, Parser } from "./router.js"; // these files only export types, so we can re-export them as-is // in TS 5.0 we'll be able to use `export type * from ...` @@ -184,4 +184,24 @@ export function useParams(): T extends string ? DefaultParams : T; +/* + * Helpers + */ + +export function matchRoute< + T extends DefaultParams | undefined = undefined, + RoutePath extends PathPattern = PathPattern +>( + parser: Parser, + pattern: RoutePath, + path: string, + loose?: boolean +): Match< + T extends DefaultParams + ? T + : RoutePath extends string + ? StringRouteParams + : RegexRouteParams +>; + // tslint:enable:no-unnecessary-generics