// Type definitions for React Router 4.0 // Project: https://github.com/ReactTraining/react-router // Definitions by: Sergey Buturlakin // Yuichi Murata // Václav Ostrožlík // Nathan Brown // Alex Wendland // Kostya Esmukov // John Reilly // Karol Janyst // Dovydas Navickas // Tanguy Krotoff // Huy Nguyen // Jérémy Fauvel // Daniel Roth // Egor Shulga // Youen Toupin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 import * as React from 'react'; import * as H from 'history'; // This is the type of the context object that will be passed down to all children of // a `Router` component: export interface RouterChildContext

{ router: { history: H.History route: { location: H.Location match: match

} }; } export interface MemoryRouterProps { initialEntries?: H.LocationDescriptor[]; initialIndex?: number; getUserConfirmation?: ((message: string, callback: (ok: boolean) => void) => void); keyLength?: number; } export class MemoryRouter extends React.Component { } export interface PromptProps { message: string | ((location: H.Location) => string | boolean); when?: boolean; } export class Prompt extends React.Component { } export interface RedirectProps { to: H.LocationDescriptor; push?: boolean; from?: string; path?: string; exact?: boolean; strict?: boolean; } export class Redirect extends React.Component { } export interface RouteComponentProps

{ match: match

; location: H.Location; history: H.History; staticContext?: any; } export interface RouteProps { location?: H.Location; component?: React.ComponentType> | React.ComponentType; render?: ((props: RouteComponentProps) => React.ReactNode); children?: ((props: RouteComponentProps) => React.ReactNode) | React.ReactNode; path?: string; exact?: boolean; strict?: boolean; } export class Route extends React.Component { } export interface RouterProps { history: any; } export class Router extends React.Component { } export interface StaticRouterProps { basename?: string; location?: string | object; context?: object; } export class StaticRouter extends React.Component { } export interface SwitchProps { children?: React.ReactNode; location?: H.Location; } export class Switch extends React.Component { } export interface match

{ params: P; isExact: boolean; path: string; url: string; } // Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 export type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; export type Omit = Pick>; export function matchPath

(pathname: string, props: RouteProps): match

| null; // There is a known issue in TypeScript, which doesn't allow decorators to change the signature of the classes // they are decorating. Due to this, if you are using @withRouter decorator in your code, // you will see a bunch of errors from TypeScript. The current workaround is to use withRouter() as a function call // on a separate line instead of as a decorator. export function withRouter

>(component: React.ComponentType

): React.ComponentClass>>;