1

Trying to initialize router with react and typescript but getting bunch of errors

Errors

I tried already install npm install @types/history But nothing changed Hope your help. Thanks

My packge.json

"dependencies": {
"@types/lodash": "^4.14.50",
"@types/react": "^0.14.55",
"@types/react-dom": "^0.14.19",
"@types/redux-form": "^6.3.2",
"animate": "^1.0.0",
"animate.css": "^3.5.2",
"bootstrap": "^4.0.0-alpha.5",
"node-sass": "^4.1.1",
"postcss-smart-import": "^0.6.6",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"react-redux": "^5.0.2",
"react-router": "^3.0.1",
"redux": "^3.6.0",
"redux-form": "^6.4.3",
"typings": "^2.1.0"
},

 "devDependencies": {
    "@types/history": "^4.5.0",
    "@types/react-router": "^2.0.44",
    "awesome-typescript-loader": "^3.0.0-beta.17",
    "css-loader": "^0.26.1",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.9.0",
    "postcss-loader": "^1.2.1",
    "precss": "^1.4.0",
    "react-hot-loader": "^1.3.1",
    "redux-devtools": "^3.3.1",
    "resolve-url-loader": "^1.6.1",
    "sass-loader": "^4.1.1",
    "source-map-loader": "^0.1.5",
    "style-loader": "^0.13.1",
    "typescript": "^2.1.4",
    "webpack": "^1.14.0"
  }
3
  • So, the typescript compiler can't find a few types. Can you post a code snippet? Don't post all of the code, just the relevant portions. Commented Jan 14, 2017 at 15:47
  • U wanted this? or? import {Router, browserHistory} from 'react-router'; ReactDOM.render(<Router history={browserHistory} routes={Routes} />, document.getElementById("miramir-app")); Commented Jan 14, 2017 at 16:05
  • hmmm...also, please update the question with your tsconfig. Commented Jan 15, 2017 at 0:24

1 Answer 1

1

Had the same issue for the time being I copied the contents of the DefinitelyTyped history v2

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/history/v2

Into my node_modues/@types/history folder

Sign up to request clarification or add additional context in comments.

1 Comment

Just a note this is just a tmp fix until the @types/history or @types/react-router is updated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.