Skip to content

Commit cf98870

Browse files
committed
fix: use react-router route param types
1 parent 11239de commit cf98870

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/reactant-router-dom/src/generatePath.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pathToRegexp from 'path-to-regexp';
22
import type * as ReactRouterDom from 'react-router-dom';
3+
import type { ExtractRouteParams } from 'react-router';
34

45
const cache: Record<string, pathToRegexp.PathFunction> = {};
56
const cacheLimit = 10000;
@@ -20,11 +21,9 @@ const compilePath = (path: string) => {
2021

2122
export const generatePath: typeof ReactRouterDom.generatePath = <S extends string>(
2223
path: S = '/' as S,
23-
params?: ReactRouterDom.ExtractRouteParams<S, string | number | boolean>
24+
params?: ExtractRouteParams<S, string | number | boolean>
2425
) => {
25-
const nextParams =
26-
params ??
27-
({} as ReactRouterDom.ExtractRouteParams<S, string | number | boolean>);
26+
const nextParams = params ?? ({} as ExtractRouteParams<S, string | number | boolean>);
2827

2928
return path === '/' ? path : compilePath(path)(nextParams, { pretty: true });
3029
};

0 commit comments

Comments
 (0)