无法在React JS中编译

时间:2018-10-18 11:43:54

标签: reactjs typescript react-router node-modules redux-saga

我是React JS的新手,我正在为我的客户开发一个React JS和Redux Saga的网站。我已经为项目安装了所有必需的模块,但仍然给我一个错误。 我也尝试过降级版本,但是仍然遇到相同的错误。 该项目在正在帮助我完成此项目的同事的笔记本电脑上运行。

Map<fieldA, A> 

这是我的ts.json文件

 This is my package.json file

{
    "name": "typescript-redux-starter-kit",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "@types/jest": "^20.0.8",
        "@types/node": "^8.0.26",
        "@types/qs": "^6.5.0",
        "@types/react": "^16.0.5",
        "@types/react-dom": "^15.5.4",
        "@types/react-redux": "^5.0.7",
        "@types/react-router-dom": "^4.0.7",
        "@types/react-router-redux": "^5.0.8",
        "app-root-path": "^2.0.1",
        "autoprefixer": "7.1.1",
        "axios": "^0.16.2",
        "bootstrap": "^4.1.3",
        "case-sensitive-paths-webpack-plugin": "2.1.1",
        "chalk": "1.1.3",
        "cli-highlight": "1.1.4",
        "css-loader": "0.28.4",
        "dotenv": "4.0.0",
        "extract-text-webpack-plugin": "2.1.2",
        "file-loader": "0.11.2",
        "fs-extra": "3.0.1",
        "history": "^4.7.2",
        "html-webpack-plugin": "2.28.0",
        "install": "^0.10.1",
        "jest": "20.0.3",
        "moment": "^2.18.1",
        "node-sass": "^4.5.3",
        "npm": "^5.4.1",
        "object-assign": "4.1.1",
        "postcss-flexbugs-fixes": "3.0.0",
        "postcss-loader": "2.0.5",
        "promise": "7.1.1",
        "qs": "^6.5.1",
        "react": "^15.6.2",
        "react-dev-utils": "^3.0.1",
        "react-dom": "^15.6.2",
        "react-error-overlay": "^1.0.8",
        "react-redux": "^5.0.6",
        "react-router-dom": "^4.2.2",
        "react-router-redux": "^5.0.0-alpha.6",
        "reactstrap": "^6.5.0",
        "redux": "^3.7.2",
        "redux-saga": "^0.15.6",
        "redux-saga-router": "^2.1.1",
        "reselect": "^3.0.1",
        "sass-loader": "^6.0.6",
        "source-map-loader": "^0.2.1",
        "style-loader": "0.18.2",
        "sw-precache-webpack-plugin": "0.11.3",
        "ts-jest": "^20.0.7",
        "ts-loader": "^2.2.1",
        "tslint": "^5.2.0",
        "tslint-loader": "^3.5.3",
        "tslint-react": "^3.0.0",
        "typescript": "~2.4.0",
        "url-loader": "0.5.8",
        "webpack": "2.6.1",
        "webpack-dev-server": "2.5.0",
        "webpack-manifest-plugin": "1.1.0",
        "whatwg-fetch": "2.0.3",
        "wildstring": "^1.0.9"
    },
    "scripts": {
        "start": "node scripts/start.js",
        "build": "node scripts/build.js",
        "test": "node scripts/test.js --env=jsdom"
    },
    "jest": {
        "mapCoverage": true,
        "collectCoverageFrom": [
            "src/**/*.{js,jsx,ts,tsx}"
        ],
        "setupFiles": [
            "<rootDir>/config/polyfills.js"
        ],
        "modulePaths": [
            "src",
            "src/modules"
        ],
        "moduleFileExtensions": [
            "web.ts",
            "ts",
            "web.tsx",
            "tsx",
            "web.js",
            "js",
            "web.jsx",
            "jsx",
            "json"
        ],
        "testMatch": [
            "<rootDir>/src/**/__tests__/**/*.ts?(x)",
            "<rootDir>/src/**/?(*.)(spec|test).ts?(x)"
        ],
        "testEnvironment": "node",
        "testURL": "http://localhost",
        "transform": {
            "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
            "^.+\\.tsx?$": "<rootDir>/config/jest/typescriptTransform.js",
            "^(?!.*\\.(css|json)$)": "<rootDir>/config/jest/fileTransform.js"
        },
        "transformIgnorePatterns": [
            "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$"
        ],
        "moduleNameMapper": {
            "^react-native$": "react-native-web"
        },
        "globals": {
            "ts-jest": {
                "tsConfigFile": "/Users/robby.emmert/CQL/cql/typescript-redux-starter-kit/tsconfig.test.json"
            }
        }
    },
    "babel": {
        "presets": [
            "react-app"
        ]
    },
    "eslintConfig": {
        "extends": "react-app"
    },
    "devDependencies": {
        "@types/enzyme": "^2.8.8",
        "@types/reactstrap": "^6.4.2",
        "enzyme": "^2.9.1",
        "eslint-config-react-app": "^2.0.0",
        "react-test-renderer": "^15.6.1"
    }
}

这是我运行项目时显示的错误:

Error message

1 个答案:

答案 0 :(得分:0)

您需要将TypeScript升级到2.8版或更高版本,因为@types/react-router取决于TypeScript 2.8中添加的Exclude类型别名。 (请注意,node_modules/@types/react-router/index.d.ts文件顶部的注释指定了所需的最低TypeScript版本。)由于每个版本都进行了改进,因此我建议将TypeScript升级到最新的稳定版本(当前为3.1.3)。 / p>