diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 847226e2f7..ff80e92992 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -127,7 +127,7 @@ export interface match { // Omit taken from https://github.com/Microsoft/TypeScript/issues/28339#issuecomment-467220238 export type Omit = T extends any ? Pick> : never; -export function matchPath(pathname: string, props: string | RouteProps, parent?: match | null): match | null; +export function matchPath(pathname: string, props: string | string[] | RouteProps, parent?: match | null): match | null; export function generatePath(pattern: string, params?: { [paramName: string]: string | number | boolean | undefined }): string; @@ -156,5 +156,5 @@ export function useLocation(): H.Location; export function useParams(): { [p in keyof Params]: string }; export function useRouteMatch( - path?: string | RouteProps, + path?: string | string[] | RouteProps, ): match | null; diff --git a/types/react-router/test/hooks.tsx b/types/react-router/test/hooks.tsx index d6a8927df2..0fe2761b55 100644 --- a/types/react-router/test/hooks.tsx +++ b/types/react-router/test/hooks.tsx @@ -15,7 +15,8 @@ const HooksTest: React.FC = () => { const { id } = useParams(); const params = useParams(); const match1 = useRouteMatch('/:id'); - const match2 = useRouteMatch({ path: '/:id', exact: true }); + const match2 = useRouteMatch(['/one/:id', '/two/:id']); + const match3 = useRouteMatch({ path: '/:id', exact: true }); history.location.state.s; location.state.s;