diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 8398838aef..2b10a4cbcb 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -3,6 +3,19 @@ // Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov , Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/* Replacement from old history definitions */ +export interface HistoryOptions { + getCurrentLocation?(): Location; + getUserConfirmation?(message: string, callback: (result: boolean) => void): void; + pushLocation?(nextLocation: Location): void; + replaceLocation?(nextLocation: Location): void; + go?(n: number): void; + keyLength?: number; +} + +export type CreateHistory = (options?: HistoryOptions) => T; +export type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory; + export { Basename, ChangeHook, diff --git a/react-router/lib/Router.d.ts b/react-router/lib/Router.d.ts index 160694953f..dbd2d43fff 100644 --- a/react-router/lib/Router.d.ts +++ b/react-router/lib/Router.d.ts @@ -1,5 +1,6 @@ import { Component, ComponentClass, ClassAttributes, ReactNode, StatelessComponent } from "react"; import { + Action, Hash, History, Href, @@ -11,12 +12,13 @@ import { } from "history"; import { PlainRoute } from "react-router"; +/* Replacement from old history definitions */ export type Basename = string; export type Query = any; -export type Action = "PUSH" | "REPLACE" | "POP"; export interface Params { [key: string]: string; } + export type RoutePattern = string; export type RouteComponent = ComponentClass | StatelessComponent; export interface RouteComponents { diff --git a/react-router/lib/createMemoryHistory.d.ts b/react-router/lib/createMemoryHistory.d.ts index bb2fed561b..038e707e6b 100644 --- a/react-router/lib/createMemoryHistory.d.ts +++ b/react-router/lib/createMemoryHistory.d.ts @@ -1,4 +1,5 @@ -import { History, CreateHistory } from "history"; +import { History } from "history"; +import { CreateHistory } from "react-router"; declare const createMemoryHistory: CreateHistory; diff --git a/react-router/lib/useRouterHistory.d.ts b/react-router/lib/useRouterHistory.d.ts index 1371baa07b..7dc2bdd3ab 100644 --- a/react-router/lib/useRouterHistory.d.ts +++ b/react-router/lib/useRouterHistory.d.ts @@ -1,5 +1,6 @@ -import { History, CreateHistoryEnhancer } from "history"; +import { History } from "history"; +import { CreateHistoryEnhancer } from "react-router"; -declare const useRouterHistory: CreateHistoryEnhancer; +declare const useRouterHistory: CreateHistoryEnhancer; export default useRouterHistory;