Skip to content

Commit

Permalink
wouter-preact: add matchRoute export to types.
Browse files Browse the repository at this point in the history
  • Loading branch information
molefrog committed Aug 24, 2024
1 parent 110b669 commit 3bbf10a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/wouter-preact/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...`
Expand Down Expand Up @@ -184,4 +184,24 @@ export function useParams<T = undefined>(): 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<RoutePath>
: RegexRouteParams
>;

// tslint:enable:no-unnecessary-generics

0 comments on commit 3bbf10a

Please sign in to comment.