diff --git a/types/history/createMemoryHistory.d.ts b/types/history/createMemoryHistory.d.ts index e1aca026e2..6142f4e3a4 100644 --- a/types/history/createMemoryHistory.d.ts +++ b/types/history/createMemoryHistory.d.ts @@ -1,4 +1,4 @@ -import { History, Location } from './index'; +import { History, Location, LocationState } from './index'; import { getConfirmation } from './DOMUtils'; export interface MemoryHistoryBuildOptions { @@ -8,9 +8,9 @@ export interface MemoryHistoryBuildOptions { keyLength?: number; } -export interface MemoryHistory extends History { +export interface MemoryHistory extends History { index: number; - entries: Location[]; + entries: Location[]; canGo(n: number): boolean; } diff --git a/types/history/history-tests.ts b/types/history/history-tests.ts index 0a63059b12..689035c9ed 100644 --- a/types/history/history-tests.ts +++ b/types/history/history-tests.ts @@ -1,4 +1,4 @@ -import { createBrowserHistory, createMemoryHistory, createHashHistory, createLocation, Location } from 'history'; +import { createBrowserHistory, createMemoryHistory, createHashHistory, createLocation, Location, History, MemoryHistory } from 'history'; import * as LocationUtils from 'history/LocationUtils'; import * as PathUtils from 'history/PathUtils'; import * as DOMUtils from 'history/DOMUtils'; @@ -7,7 +7,7 @@ import * as ExecutionEnvironment from 'history/ExecutionEnvironment'; let input = { value: "" }; { - let history = createBrowserHistory(); + let history: History<{some: 'state'}> = createBrowserHistory(); // Listen for changes to the current location. The // listener is called once immediately. @@ -43,7 +43,7 @@ let input = { value: "" }; } { - let history = createMemoryHistory(); + let history: MemoryHistory<{the: 'state'}> = createMemoryHistory(); // Pushing a path string. history.push('/the/path'); diff --git a/types/history/index.d.ts b/types/history/index.d.ts index 1c7b35b8f2..3fff510bd2 100644 --- a/types/history/index.d.ts +++ b/types/history/index.d.ts @@ -8,20 +8,20 @@ export as namespace History; export type Action = 'PUSH' | 'POP' | 'REPLACE'; export type UnregisterCallback = () => void; -export interface History { +export interface History { length: number; action: Action; - location: Location; - push(path: Path, state?: LocationState): void; - push(location: LocationDescriptorObject): void; - replace(path: Path, state?: LocationState): void; - replace(location: LocationDescriptorObject): void; + location: Location; + push(path: Path, state?: HistoryLocationState): void; + push(location: LocationDescriptorObject): void; + replace(path: Path, state?: HistoryLocationState): void; + replace(location: LocationDescriptorObject): void; go(n: number): void; goBack(): void; goForward(): void; block(prompt?: boolean | string | TransitionPromptHook): UnregisterCallback; listen(listener: LocationListener): UnregisterCallback; - createHref(location: LocationDescriptorObject): Href; + createHref(location: LocationDescriptorObject): Href; } export interface Location {