import * as React from "react"; export interface HLocation { pathname: string; search: string; state: S; hash: string; key?: string | undefined; } export type WindowLocation = Window["location"] & HLocation; export type HistoryActionType = "PUSH" | "POP"; export type HistoryLocation = WindowLocation & { state?: any }; export interface HistoryListenerParameter { location: HistoryLocation; action: HistoryActionType; } export type HistoryListener = (parameter: HistoryListenerParameter) => void; export type HistoryUnsubscribe = () => void; export interface History { readonly location: HistoryLocation; readonly transitioning: boolean; listen: (listener: HistoryListener) => HistoryUnsubscribe; navigate: NavigateFn; } export class Router extends React.Component> {} export interface RouterProps { basepath?: string | undefined; primary?: boolean | undefined; location?: WindowLocation | undefined; component?: React.ComponentType | string | undefined; } export type RouteComponentProps = Partial & { path?: string | undefined; default?: boolean | undefined; location?: WindowLocation | undefined; navigate?: NavigateFn | undefined; uri?: string | undefined; }; export type Omit = Pick>; export type AnchorProps = Omit< React.DetailedHTMLProps, HTMLAnchorElement>, "href" // remove href, as it's ignored by the router >; export interface LinkProps extends AnchorProps { to: string; replace?: boolean | undefined; getProps?: ((props: LinkGetProps) => {}) | undefined; state?: TState | undefined; /** @deprecated If using React >= 16.4, use ref instead. */ innerRef?: React.Ref | undefined; } export interface LinkGetProps { isCurrent: boolean; isPartiallyCurrent: boolean; href: string; location: WindowLocation; } export function Link( // TODO: Define this as ...params: Parameters> when only TypeScript >= 3.1 support is needed. props: React.PropsWithoutRef> & React.RefAttributes, ): ReturnType>; export interface Link extends React.ForwardRefExoticComponent< React.PropsWithoutRef> & React.RefAttributes > {} export interface RedirectProps { from?: string | undefined; to: string; noThrow?: boolean | undefined; state?: TState | undefined; replace?: boolean | undefined; } export class Redirect extends React.Component>> {} export interface MatchProps { path: string; children: MatchRenderFn; } export type MatchRenderFn = (props: MatchRenderProps) => React.ReactNode; export interface MatchRenderProps { match: null | ({ uri: string; path: string } & TParams); location: WindowLocation; navigate: NavigateFn; } export class Match extends React.Component> {} export interface NavigateFn { (to: string, options?: NavigateOptions<{}>): Promise; (to: number, options?: undefined): Promise; } export interface NavigateOptions { state?: TState | undefined; replace?: boolean | undefined; } export interface LocationProps { children: LocationProviderRenderFn; } export class Location extends React.Component {} export interface LocationProviderProps { history?: History | undefined; children?: React.ReactNode | LocationProviderRenderFn | undefined; } export type LocationProviderRenderFn = (context: LocationContext) => React.ReactNode; export interface LocationContext { location: WindowLocation; navigate: NavigateFn; } export class LocationProvider extends React.Component {} export interface ServerLocationProps { url: string; } export class ServerLocation extends React.Component {} export const navigate: NavigateFn; export interface HistorySource { readonly location: WindowLocation; addEventListener(name: string, listener: (event: Event) => void): void; removeEventListener(name: string, listener: (event: Event) => void): void; history: { readonly state: any; pushState(state: any, title: string, uri: string): void; replaceState(state: any, title: string, uri: string): void; }; } export function createHistory(source: HistorySource): History; export function createMemorySource(initialPath: string): HistorySource; export interface RedirectRequest { uri: string; } export function isRedirect(error: any): error is RedirectRequest; export function redirectTo(uri: string): void; export const globalHistory: History; export function useLocation(): WindowLocation; export function useNavigate(): NavigateFn; // TODO: In the next major release update we should update the type parameter default of TPrams from `any` to `{}`, // it is currently being keep for backwards compatibility with version 1.3.7 or below. export function useParams(): TParams; export function useMatch(pathname: string): null | { uri: string; path: string; [param: string]: string };