@types/react-router
Advanced tools
Comparing version 5.1.11 to 5.1.12
@@ -86,8 +86,11 @@ // Type definitions for React Router 5.1 | ||
export interface RouteProps { | ||
export interface RouteProps< | ||
Path extends string = string, | ||
Params extends { [K: string]: string | undefined } = ExtractRouteParams<Path, string> | ||
> { | ||
location?: H.Location; | ||
component?: React.ComponentType<RouteComponentProps<any>> | React.ComponentType<any>; | ||
render?: (props: RouteComponentProps<any>) => React.ReactNode; | ||
children?: ((props: RouteChildrenProps<any>) => React.ReactNode) | React.ReactNode; | ||
path?: string | string[]; | ||
render?: (props: RouteComponentProps<Params>) => React.ReactNode; | ||
children?: ((props: RouteChildrenProps<Params>) => React.ReactNode) | React.ReactNode; | ||
path?: Path | Path[]; | ||
exact?: boolean; | ||
@@ -97,3 +100,6 @@ sensitive?: boolean; | ||
} | ||
export class Route<T extends RouteProps = RouteProps> extends React.Component<T, any> {} | ||
export class Route<T extends {} = {}, Path extends string = string> extends React.Component< | ||
RouteProps<Path> & OmitNative<T, keyof RouteProps>, | ||
any | ||
> {} | ||
@@ -133,2 +139,5 @@ export interface RouterProps { | ||
// Newer Omit type: as the previous one is being exported, removing it would be a breaking change | ||
export type OmitNative<T, K extends string | number | symbol> = { [P in Exclude<keyof T, K>]: T[P] }; | ||
export function matchPath<Params extends { [K in keyof Params]?: string }>( | ||
@@ -140,12 +149,12 @@ pathname: string, | ||
export type ExtractRouteOptionalParam<T extends string> = T extends `${infer Param}?` | ||
? { [k in Param]?: string | number | boolean } | ||
: { [k in T]: string | number | boolean }; | ||
export type ExtractRouteOptionalParam<T extends string, U = string | number | boolean> = T extends `${infer Param}?` | ||
? { [k in Param]?: U } | ||
: { [k in T]: U }; | ||
export type ExtractRouteParams<T extends string> = string extends T | ||
? { [k in string]?: string | number | boolean } | ||
export type ExtractRouteParams<T extends string, U = string | number | boolean> = string extends T | ||
? { [k in string]?: U } | ||
: T extends `${infer _Start}:${infer Param}/${infer Rest}` | ||
? ExtractRouteOptionalParam<Param> & ExtractRouteParams<Rest> | ||
? ExtractRouteOptionalParam<Param, U> & ExtractRouteParams<Rest, U> | ||
: T extends `${infer _Start}:${infer Param}` | ||
? ExtractRouteOptionalParam<Param> | ||
? ExtractRouteOptionalParam<Param, U> | ||
: {}; | ||
@@ -152,0 +161,0 @@ |
{ | ||
"name": "@types/react-router", | ||
"version": "5.1.11", | ||
"version": "5.1.12", | ||
"description": "TypeScript definitions for React Router", | ||
@@ -127,4 +127,4 @@ "license": "MIT", | ||
}, | ||
"typesPublisherContentHash": "961c2fa917a2e0fb12404dd928f6e7ce482dd9b54353b0fca2443ffd9151937c", | ||
"typeScriptVersion": "3.3" | ||
"typesPublisherContentHash": "cbc35e382f4f32a43190d682ad28311613bf611cf4b9553a199a6d6c6a123249", | ||
"typeScriptVersion": "3.4" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Fri, 08 Jan 2021 18:07:12 GMT | ||
* Last updated: Mon, 01 Mar 2021 18:55:43 GMT | ||
* Dependencies: [@types/react](https://npmjs.com/package/@types/react), [@types/history](https://npmjs.com/package/@types/history) | ||
@@ -14,0 +14,0 @@ * Global values: none |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18728
281