Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit f8714e9

Browse files
Fix react/redux TypeScript build errors caused by breaking changes in dependencies. Fixes #529, #582, #583
1 parent 9d50061 commit f8714e9

File tree

6 files changed

+28
-8
lines changed

6 files changed

+28
-8
lines changed

samples/react/MusicStore/ReactApp/configureStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createStore, applyMiddleware, compose, combineReducers, GenericStoreEnhancer } from 'redux';
1+
import { createStore, applyMiddleware, compose, combineReducers, GenericStoreEnhancer, Store as ReduxStore } from 'redux';
22
import thunk from 'redux-thunk';
33
import { routerReducer } from 'react-router-redux';
44
import * as Store from './store';
@@ -16,7 +16,7 @@ export default function configureStore(initialState?: Store.ApplicationState) {
1616

1717
// Combine all reducers and instantiate the app-wide store instance
1818
const allReducers = buildRootReducer(Store.reducers);
19-
const store = createStoreWithMiddleware(allReducers, initialState) as Redux.Store<Store.ApplicationState>;
19+
const store = createStoreWithMiddleware(allReducers, initialState) as ReduxStore<Store.ApplicationState>;
2020

2121
// Enable Webpack hot module replacement for reducers
2222
if (module.hot) {

samples/react/MusicStore/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "music-store",
33
"version": "0.0.0",
44
"dependencies": {
5+
"@types/history": "^2.0.0",
56
"@types/react": "^0.14.29",
67
"@types/react-bootstrap": "^0.0.35",
78
"@types/react-dom": "^0.14.14",
@@ -41,7 +42,7 @@
4142
"redux-typed": "^2.0.0",
4243
"style-loader": "^0.13.0",
4344
"ts-loader": "^0.8.1",
44-
"typescript": "2.0.3",
45+
"typescript": "^2.0.3",
4546
"url-loader": "^0.5.7",
4647
"webpack": "^1.13.2",
4748
"webpack-hot-middleware": "^2.12.2",

samples/react/MusicStore/tsconfig.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
{
22
"compilerOptions": {
3+
"baseUrl": ".",
34
"moduleResolution": "node",
45
"target": "es6",
56
"jsx": "preserve",
67
"sourceMap": true,
78
"experimentalDecorators": true,
8-
"types": [ "webpack-env", "whatwg-fetch" ]
9+
"types": [ "webpack-env", "whatwg-fetch" ],
10+
"paths": {
11+
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
12+
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
13+
"history": ["./node_modules/@types/history/index"],
14+
"redux": ["./node_modules/@types/redux/index"],
15+
"react": ["./node_modules/@types/react/index"]
16+
}
917
},
1018
"exclude": [
1119
"node_modules"

templates/ReactReduxSpa/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "WebApplicationBasic",
33
"version": "0.0.0",
44
"dependencies": {
5+
"@types/history": "^2.0.0",
56
"@types/react": "^0.14.29",
67
"@types/react-dom": "^0.14.14",
78
"@types/react-redux": "^4.4.29",
@@ -39,7 +40,7 @@
3940
"redux-thunk": "^2.1.0",
4041
"style-loader": "^0.13.0",
4142
"ts-loader": "^0.8.1",
42-
"typescript": "2.0.3",
43+
"typescript": "^2.0.3",
4344
"url-loader": "^0.5.7",
4445
"webpack": "^1.13.2",
4546
"webpack-hot-middleware": "^2.12.2",

templates/ReactReduxSpa/tsconfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
"lib": ["es6", "dom"],
1111
"types": [ "webpack-env", "whatwg-fetch" ],
1212
"paths": {
13-
// Fixes "Duplicate identifier 'Redux'" error when packages were installed via Yarn (by specifying which .d.ts file is authoritative)
14-
"redux": ["./node_modules/@types/redux/index"]
13+
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
14+
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
15+
"history": ["./node_modules/@types/history/index"],
16+
"redux": ["./node_modules/@types/redux/index"],
17+
"react": ["./node_modules/@types/react/index"]
1518
}
1619
},
1720
"exclude": [

templates/ReactSpa/tsconfig.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{
22
"compilerOptions": {
3+
"baseUrl": ".",
34
"moduleResolution": "node",
45
"target": "es6",
56
"jsx": "preserve",
67
"sourceMap": true,
7-
"skipDefaultLibCheck": true
8+
"skipDefaultLibCheck": true,
9+
"paths": {
10+
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
11+
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
12+
"history": ["./node_modules/@types/history/index"],
13+
"react": ["./node_modules/@types/react/index"]
14+
}
815
},
916
"exclude": [
1017
"bin",

0 commit comments

Comments
 (0)