6

After installing the required packages to run react-redux and @reduxjs//toolkit in my current projects, I ran into this error after running npm start:

TypeScript error in C:/Users/xxx/Documents/xxx/node_modules/@reduxjs/toolkit/dist/configureStore.d.ts(1,13):
'=' expected.  TS1005
 1 | import type { Reducer, ReducersMapObject, Middleware, Action, AnyAction, StoreEnhancer, Store, Dispatch, PreloadedState, CombinedState } from 'redux';

My store is this:

import { configureStore } from "@reduxjs/toolkit";
import securityReducer from "../features/security/securitySlice.js";
const store = configureStore({
    reducer: {
      security: securityReducer,
  },
  });
export default store;

My index.tsx file contains this:

import React, { useEffect, useState } from "react";
import ReactDOM from "react-dom";`
import "./index.css";`
import AppContainer from "./AppContainer.js";
import * as serviceWorker from "./serviceWorker";
import store from "./app/store.jsx";
import { Provider } from "react-redux";
ReactDOM.render(
  <React.StrictMode>
    <Provider store={store}>
      <AppContainer />
    </Provider>
  </React.StrictMode>,
  document.getElementById("root")
);
serviceWorker.unregister();

And my package.json file is this:

{
  "name": "my-app",
  "version": "0.1.0",
  "dependencies": {
    "@aws-amplify/ui-react": "^1.2.0",
    "@material-ui/core": "^4.11.3",
    "@material-ui/icons": "^4.11.2",
    "@reduxjs/toolkit": "^1.6.1",
    "@types/react-router-dom": "^5.1.7",
    "amazon-cognito-identity-js": "^5.0.3",
    "amazon-cognito-identity-js-typescript": "^1.22.0",
    "aws-amplify": "^4.0.2",
    "aws-sdk": "^2.799.0",
    "axios": "^0.21.1",
    "bootstrap": "^4.4.1",
    "cors": "^2.8.5",
    "lodash": "^4.17.15",
    "material-ui-dropzone": "^3.5.0",
    "moment": "^2.25.3",
    "rc-slider": "~9.2.4",
    "react": "^16.13.0",
    "react-bootstrap": "^1.0.0-beta.17",
    "react-bootstrap-icons": "^1.1.0",
    "react-dom": "^16.13.0",
    "react-google-charts": "^3.0.15",
    "react-icons": "^4.2.0",
    "react-redux": "^7.2.4",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.0",
    "redux": "^4.1.0",
    "redux-ts": "^4.3.0",
    "typescript": "~3.8.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "test:coverage": "react-scripts test --watchAll=false --coverage",
    "build": "react-scripts build",
    "test": "react-scripts test --watchAll=false",
    "test:watch": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/enzyme": "^3.10.5",
    "@types/jest": "^24.0.0",
    "@types/lodash": "^4.14.149",
    "@types/node": "^12.0.0",
    "@types/rc-slider": "~8.6.5",
    "@types/react": "^16.9.0",
    "@types/react-dom": "^16.9.0",
    "@types/react-redux": "^7.1.18",
    "@types/redux": "^3.6.0",
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.2",
    "enzyme-to-json": "^3.4.4",
    "node-sass": "^4.13.1"
  }
}

I read from some posts that my version of typescript needed to be updated to 3.8 but it still doesn't seem to solve the issue.

Thank you so much if anyone knows how to fix this error.

1

1 Answer 1

3

Maybe you can upgrade your typescript version to "^4.1.2", I also have the same problem with you, and I fix that with this

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

Comments

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.