Update react-router-redux to user history 4.5.x

This commit is contained in:
Karol Janyst
2017-01-17 12:32:34 +09:00
parent 214b6845de
commit 040c1365bc
4 changed files with 76 additions and 73 deletions

View File

@@ -1,65 +1,58 @@
// Type definitions for react-router-redux v4.0.0
// Type definitions for react-router-redux 4.0
// Project: https://github.com/rackt/react-router-redux
// Definitions by: Isman Usoh <http://github.com/isman-usoh>, Noah Shipley <https://github.com/noah79>, Dimitri Rosenberg <https://github.com/rosendi>
// Definitions by: Isman Usoh <http://github.com/isman-usoh>, Noah Shipley <https://github.com/noah79>, Dimitri Rosenberg <https://github.com/rosendi>, Karol Janyst <https://github.com/LKay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="react-router"/>
import { Action, Middleware, Store } from "redux";
import { History, Location, LocationDescriptor } from "history";
import * as Redux from "redux";
import * as History from "history";
export const CALL_HISTORY_METHOD: string;
export const LOCATION_CHANGE: string;
export = ReactRouterRedux;
declare namespace ReactRouterRedux {
import R = Redux;
const CALL_HISTORY_METHOD: string;
const LOCATION_CHANGE: string;
const push: PushAction;
const replace: ReplaceAction;
const go: GoAction;
const goBack: GoForwardAction;
const goForward: GoBackAction;
const routerActions: RouteActions;
type LocationDescriptor = History.LocationDescriptor;
type PushAction = (nextLocation: LocationDescriptor) => RouterAction;
type ReplaceAction = (nextLocation: LocationDescriptor) => RouterAction;
type GoAction = (n: number) => RouterAction;
type GoForwardAction = () => RouterAction;
type GoBackAction = () => RouterAction;
type RouterAction = {
type: string
payload?: LocationDescriptor
}
interface RouteActions {
push: PushAction;
replace: ReplaceAction;
go: GoAction;
goForward: GoForwardAction;
goBack: GoBackAction;
}
interface ReactRouterReduxHistory extends History.History {
unsubscribe(): void;
}
interface DefaultSelectLocationState extends Function {
(state: any): any;
}
interface SyncHistoryWithStoreOptions {
selectLocationState?: DefaultSelectLocationState;
adjustUrlOnReplay?: boolean;
}
interface RouterState {
locationBeforeTransitions: History.Location
}
function routerReducer(state?: RouterState, action?: R.Action): RouterState;
function syncHistoryWithStore(history: History.History, store: R.Store<any>, options?: SyncHistoryWithStoreOptions): ReactRouterReduxHistory;
function routerMiddleware(history: History.History): R.Middleware;
export interface LocationActionPayload {
method: string;
args?: any[];
}
export interface RouterAction extends Action {
payload?: LocationActionPayload;
}
type LocationAction = (nextLocation: LocationDescriptor) => RouterAction;
type GoAction = (n: number) => RouterAction;
type NavigateAction = () => RouterAction;
export const push: LocationAction;
export const replace: LocationAction;
export const go: GoAction;
export const goBack: NavigateAction;
export const goForward: NavigateAction;
interface RouteActions {
push: typeof push;
replace: typeof replace;
go: typeof go;
goForward: typeof goForward;
goBack: typeof goBack;
}
export const routerActions: RouteActions;
export interface RouterState {
locationBeforeTransitions: Location
}
export type DefaultSelectLocationState = (state: any) => RouterState
export interface SyncHistoryWithStoreOptions {
selectLocationState?: DefaultSelectLocationState;
adjustUrlOnReplay?: boolean;
}
export interface HistoryUnsubscribe {
unsubscribe(): void;
}
export function routerReducer(state?: RouterState, action?: Action): RouterState;
export function syncHistoryWithStore(history: History, store: Store<any>, options?: SyncHistoryWithStoreOptions): History & HistoryUnsubscribe;
export function routerMiddleware(history: History): Middleware;

View File

@@ -1,9 +1,16 @@
/// <reference types="redux" />
/// <reference types="react-router" />
import { createStore, combineReducers, applyMiddleware } from 'redux';
import { browserHistory } from 'react-router';
import { syncHistoryWithStore, routerReducer, routerMiddleware, push, replace, go, goForward, goBack } from 'react-router-redux';
import {
syncHistoryWithStore,
routerReducer,
routerMiddleware,
push,
replace,
go,
goForward,
goBack,
routerActions
} from 'react-router-redux';
const reducer = combineReducers({ routing: routerReducer });
@@ -25,3 +32,8 @@ store.dispatch(replace('/foo'));
store.dispatch(go(1));
store.dispatch(goForward());
store.dispatch(goBack());
store.dispatch(routerActions.push('/foo'));
store.dispatch(routerActions.replace('/foo'));
store.dispatch(routerActions.go(1));
store.dispatch(routerActions.goForward());
store.dispatch(routerActions.goBack());

View File

@@ -1,23 +1,20 @@
{
"files": [
"index.d.ts",
"react-router-redux-tests.ts"
],
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"paths": {
"history": ["history/v2"]
},
"typeRoots": [
"../"
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
},
"files": [
"index.d.ts",
"react-router-redux-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "../tslint.json" }