mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
[react-router] add string[] to matchPath and useRouteMatch arg types (#39037)
This commit is contained in:
committed by
Andrew Branch
parent
b18bc628f8
commit
2d75b571cf
Vendored
+2
-2
@@ -127,7 +127,7 @@ export interface match<Params extends { [K in keyof Params]?: string } = {}> {
|
||||
// Omit taken from https://github.com/Microsoft/TypeScript/issues/28339#issuecomment-467220238
|
||||
export type Omit<T, K extends keyof T> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;
|
||||
|
||||
export function matchPath<Params extends { [K in keyof Params]?: string }>(pathname: string, props: string | RouteProps, parent?: match<Params> | null): match<Params> | null;
|
||||
export function matchPath<Params extends { [K in keyof Params]?: string }>(pathname: string, props: string | string[] | RouteProps, parent?: match<Params> | null): match<Params> | null;
|
||||
|
||||
export function generatePath(pattern: string, params?: { [paramName: string]: string | number | boolean | undefined }): string;
|
||||
|
||||
@@ -156,5 +156,5 @@ export function useLocation<S = H.LocationState>(): H.Location<S>;
|
||||
export function useParams<Params extends { [K in keyof Params]?: string } = {}>(): { [p in keyof Params]: string };
|
||||
|
||||
export function useRouteMatch<Params extends { [K in keyof Params]?: string } = {}>(
|
||||
path?: string | RouteProps,
|
||||
path?: string | string[] | RouteProps,
|
||||
): match<Params> | null;
|
||||
|
||||
@@ -15,7 +15,8 @@ const HooksTest: React.FC = () => {
|
||||
const { id } = useParams();
|
||||
const params = useParams<Params>();
|
||||
const match1 = useRouteMatch<Params>('/:id');
|
||||
const match2 = useRouteMatch<Params>({ path: '/:id', exact: true });
|
||||
const match2 = useRouteMatch<Params>(['/one/:id', '/two/:id']);
|
||||
const match3 = useRouteMatch<Params>({ path: '/:id', exact: true });
|
||||
|
||||
history.location.state.s;
|
||||
location.state.s;
|
||||
|
||||
Reference in New Issue
Block a user