diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 82811fadfb..ed158404de 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -13,6 +13,7 @@ // Huy Nguyen // Jérémy Fauvel // Daniel Roth +// Ross Allen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/react-router/v3/index.d.ts b/types/react-router/v3/index.d.ts index ce1e165c7c..10d6bb168c 100644 --- a/types/react-router/v3/index.d.ts +++ b/types/react-router/v3/index.d.ts @@ -34,6 +34,7 @@ export { RouteProps, PlainRoute } from "react-router/lib/Route"; export { IndexRouteProps } from "react-router/lib/IndexRoute"; export { RedirectProps } from "react-router/lib/Redirect"; export { IndexRedirectProps } from "react-router/lib/IndexRedirect"; +export { WithRouterProps } from "react-router/lib/withRouter"; /* components */ export { default as Router } from "react-router/lib/Router"; diff --git a/types/react-router/v3/lib/withRouter.d.ts b/types/react-router/v3/lib/withRouter.d.ts index 209c01f913..69639a887f 100644 --- a/types/react-router/v3/lib/withRouter.d.ts +++ b/types/react-router/v3/lib/withRouter.d.ts @@ -1,12 +1,22 @@ import { ComponentClass, StatelessComponent } from "react"; +import { InjectedRouter, Params } from "./Router"; +import { Location } from "history"; +import { PlainRoute } from "./Route"; interface Options { withRef?: boolean; } +export interface WithRouterProps { + location: Location; + params: Params; + router: InjectedRouter; + routes: PlainRoute[]; +} + type ComponentConstructor

= ComponentClass

| StatelessComponent

; -declare function withRouter(component: ComponentConstructor

& S, options?: Options): ComponentClass

& S; -declare function withRouter

(component: ComponentConstructor

, options?: Options): ComponentClass

; +declare function withRouter(component: ComponentConstructor

& S, options?: Options): ComponentClass

& S; +declare function withRouter

(component: ComponentConstructor

, options?: Options): ComponentClass

; export default withRouter; diff --git a/types/react-router/v3/react-router-tests.tsx b/types/react-router/v3/react-router-tests.tsx index db7537cd2b..58487fd26d 100644 --- a/types/react-router/v3/react-router-tests.tsx +++ b/types/react-router/v3/react-router-tests.tsx @@ -20,7 +20,8 @@ import { RouterContext, LinkProps, RedirectFunction, - RouteComponentProps + RouteComponentProps, + WithRouterProps } from "react-router"; import { createHistory, History } from "history"; @@ -71,11 +72,7 @@ class Master extends Component { } } -interface DashboardProps { - router: InjectedRouter; -} - -class Dashboard extends React.Component { +class Dashboard extends React.Component { static staticMethodToBeHoisted(): void { } navigate() {