Update remaining templates to TypeScript 2 / @types / etc.

This commit is contained in:
Mark Pieszak
2016-10-17 09:59:13 +01:00
committed by SteveSandersonMS
parent a7ed0112db
commit f6d7321243
44 changed files with 105 additions and 12587 deletions

View File

@@ -1,14 +1,14 @@
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import * as thunkModule from 'redux-thunk';
import { createStore, applyMiddleware, compose, combineReducers, GenericStoreEnhancer } from 'redux';
import thunk from 'redux-thunk';
import { routerReducer } from 'react-router-redux';
import * as Store from './store';
import { typedToPlain } from 'redux-typed';
export default function configureStore(initialState?: Store.ApplicationState) {
// Build middleware. These are functions that can process the actions before they reach the store.
const thunk = (thunkModule as any).default; // Workaround for TypeScript not importing thunk module as expected
const windowIfDefined = typeof window === 'undefined' ? null : window as any;
const devToolsExtension = windowIfDefined && windowIfDefined.devToolsExtension; // If devTools is installed, connect to it
// If devTools is installed, connect to it
const devToolsExtension = windowIfDefined && windowIfDefined.devToolsExtension as () => GenericStoreEnhancer;
const createStoreWithMiddleware = compose(
applyMiddleware(thunk, typedToPlain),
devToolsExtension ? devToolsExtension() : f => f
@@ -16,7 +16,7 @@ export default function configureStore(initialState?: Store.ApplicationState) {
// Combine all reducers and instantiate the app-wide store instance
const allReducers = buildRootReducer(Store.reducers);
const store = createStoreWithMiddleware(allReducers, initialState) as Redux.Store;
const store = createStoreWithMiddleware(allReducers, initialState) as Redux.Store<Store.ApplicationState>;
// Enable Webpack hot module replacement for reducers
if (module.hot) {
@@ -30,5 +30,5 @@ export default function configureStore(initialState?: Store.ApplicationState) {
}
function buildRootReducer(allReducers) {
return combineReducers(Object.assign({}, allReducers, { routing: routerReducer })) as Redux.Reducer;
return combineReducers<Store.ApplicationState>(Object.assign({}, allReducers, { routing: routerReducer }));
}