mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
add type definitions from react-router-redux
This commit is contained in:
20
react-router-redux/react-router-redux-tests.ts
Normal file
20
react-router-redux/react-router-redux-tests.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/// <reference path="./react-router-redux.d.ts" />
|
||||
/// <reference path="../redux/redux.d.ts" />
|
||||
/// <reference path="../react-router/react-router.d.ts" />
|
||||
|
||||
|
||||
|
||||
import { createStore, combineReducers, applyMiddleware } from 'redux';
|
||||
import { browserHistory } from 'react-router';
|
||||
import { syncHistory, routeReducer } from 'react-router-redux';
|
||||
|
||||
const reducer = combineReducers({ routing: routeReducer });
|
||||
|
||||
// Sync dispatched route actions to the history
|
||||
const reduxRouterMiddleware = syncHistory(browserHistory);
|
||||
const createStoreWithMiddleware = applyMiddleware(reduxRouterMiddleware)(createStore);
|
||||
|
||||
const store = createStoreWithMiddleware(reducer);
|
||||
|
||||
// Required for replaying actions from devtools to
|
||||
reduxRouterMiddleware.listenForReplays(store);
|
||||
48
react-router-redux/react-router-redux.d.ts
vendored
Normal file
48
react-router-redux/react-router-redux.d.ts
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Type definitions for react-router v2.1.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: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../redux/Redux.d.ts" />
|
||||
/// <reference path="../react-router/react-router.d.ts"/>
|
||||
|
||||
declare module ReactRouterRedux {
|
||||
import R = Redux;
|
||||
import H = HistoryModule;
|
||||
|
||||
const TRANSITION: string;
|
||||
const UPDATE_LOCATION: string;
|
||||
|
||||
const push: PushAction;
|
||||
const replace: ReplaceAction;
|
||||
const go: GoAction;
|
||||
const goBack: GoForwardAction;
|
||||
const goForward: GoBackAction;
|
||||
const routeActions: RouteActions;
|
||||
|
||||
type LocationDescriptor = H.Location | H.Path;
|
||||
type PushAction = (nextLocation: LocationDescriptor) => void;
|
||||
type ReplaceAction = (nextLocation: LocationDescriptor) => void;
|
||||
type GoAction = (n: number) => void;
|
||||
type GoForwardAction = () => void;
|
||||
type GoBackAction = () => void;
|
||||
|
||||
interface RouteActions {
|
||||
push: PushAction;
|
||||
replace: ReplaceAction;
|
||||
go: GoAction;
|
||||
goForward: GoForwardAction;
|
||||
goBack: GoBackAction;
|
||||
}
|
||||
interface HistoryMiddleware extends R.Middleware {
|
||||
listenForReplays(store: R.Store, selectLocationState?: Function): void;
|
||||
unsubscribe(): void;
|
||||
}
|
||||
|
||||
function routeReducer(state?: any, options?: any): R.Reducer;
|
||||
function syncHistory(history: H.History): HistoryMiddleware;
|
||||
}
|
||||
|
||||
declare module "react-router-redux" {
|
||||
export = ReactRouterRedux;
|
||||
}
|
||||
Reference in New Issue
Block a user