From c891948be21d354da885ea0b47c5f624d12ddda0 Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Wed, 27 Jan 2016 21:24:52 +0700 Subject: [PATCH 1/4] add type definitions from react-router-redux --- .../react-router-redux-tests.ts | 20 ++++++++ react-router-redux/react-router-redux.d.ts | 48 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 react-router-redux/react-router-redux-tests.ts create mode 100644 react-router-redux/react-router-redux.d.ts diff --git a/react-router-redux/react-router-redux-tests.ts b/react-router-redux/react-router-redux-tests.ts new file mode 100644 index 000000000..98fcdca1b --- /dev/null +++ b/react-router-redux/react-router-redux-tests.ts @@ -0,0 +1,20 @@ +/// +/// +/// + + + +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); diff --git a/react-router-redux/react-router-redux.d.ts b/react-router-redux/react-router-redux.d.ts new file mode 100644 index 000000000..1c67b3baf --- /dev/null +++ b/react-router-redux/react-router-redux.d.ts @@ -0,0 +1,48 @@ +// Type definitions for react-router v2.1.0 +// Project: https://github.com/rackt/react-router-redux +// Definitions by: Isman Usoh , Noah Shipley , Dimitri Rosenberg +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +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; +} From 8cf699583ca3601beaa01e63ae8a09dc0dd48149 Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Wed, 27 Jan 2016 21:33:05 +0700 Subject: [PATCH 2/4] Update react-router-redux.d.ts --- react-router-redux/react-router-redux.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-router-redux/react-router-redux.d.ts b/react-router-redux/react-router-redux.d.ts index 1c67b3baf..6ada2e321 100644 --- a/react-router-redux/react-router-redux.d.ts +++ b/react-router-redux/react-router-redux.d.ts @@ -3,7 +3,7 @@ // Definitions by: Isman Usoh , Noah Shipley , Dimitri Rosenberg // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// /// declare module ReactRouterRedux { From 26e76daaf55db14afe0a5da04447e559966fadfe Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Wed, 27 Jan 2016 21:42:17 +0700 Subject: [PATCH 3/4] Update react-router-redux.d.ts --- react-router-redux/react-router-redux.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-router-redux/react-router-redux.d.ts b/react-router-redux/react-router-redux.d.ts index 6ada2e321..a0cf53e77 100644 --- a/react-router-redux/react-router-redux.d.ts +++ b/react-router-redux/react-router-redux.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-router v2.1.0 +// Type definitions for react-router-redux v2.1.0 // Project: https://github.com/rackt/react-router-redux // Definitions by: Isman Usoh , Noah Shipley , Dimitri Rosenberg // Definitions: https://github.com/borisyankov/DefinitelyTyped From e6236157ce37fe1c8f2e3babd0bee364d8788c8b Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Thu, 28 Jan 2016 02:25:25 +0700 Subject: [PATCH 4/4] Update react-router-redux.d.ts fix tslint errors no-internal-module --- react-router-redux/react-router-redux.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-router-redux/react-router-redux.d.ts b/react-router-redux/react-router-redux.d.ts index a0cf53e77..7248fb3af 100644 --- a/react-router-redux/react-router-redux.d.ts +++ b/react-router-redux/react-router-redux.d.ts @@ -6,7 +6,7 @@ /// /// -declare module ReactRouterRedux { +declare namespace ReactRouterRedux { import R = Redux; import H = HistoryModule;