Update some definitions based on history v2

This commit is contained in:
Karol Janyst
2017-01-19 09:46:36 +09:00
parent 69a9f6d671
commit d11a1c562b
4 changed files with 21 additions and 4 deletions

View File

@@ -3,6 +3,19 @@
// Definitions by: Sergey Buturlakin <https://github.com/sergey-buturlakin>, Yuichi Murata <https://github.com/mrk21>, Václav Ostrožlík <https://github.com/vasek17>, Nathan Brown <https://github.com/ngbrown>, Alex Wendland <https://github.com/awendland>, Kostya Esmukov <https://github.com/KostyaEsmukov>, Karol Janyst <https://github.com/LKay>
// 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<T> = (options?: HistoryOptions) => T;
export type CreateHistoryEnhancer<T> = (createHistory: CreateHistory<T>) => CreateHistory<T>;
export {
Basename,
ChangeHook,

View File

@@ -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<any> | StatelessComponent<any>;
export interface RouteComponents {

View File

@@ -1,4 +1,5 @@
import { History, CreateHistory } from "history";
import { History } from "history";
import { CreateHistory } from "react-router";
declare const createMemoryHistory: CreateHistory<History>;

View File

@@ -1,5 +1,6 @@
import { History, CreateHistoryEnhancer } from "history";
import { History } from "history";
import { CreateHistoryEnhancer } from "react-router";
declare const useRouterHistory: CreateHistoryEnhancer<History, any>;
declare const useRouterHistory: CreateHistoryEnhancer<History>;
export default useRouterHistory;