在tsconfig.json

时间:2018-10-17 01:22:25

标签: javascript reactjs typescript

我正在使用打字稿和redux在React应用程序中工作。我更新了几个npm软件包,它们之间是typescript软件包,现在是tsconfig.json(typescrip编译器配置文件),向我显示以下错误:

  

找不到'redux-logger'的类型定义文件

我尝试在此处和Google上搜索该问题,但找不到tsconfig.json中需要包含的内容。这是文件的内容:

{
  "compilerOptions": {
    "outDir": "build/dist",
    "module": "esnext",
    "target": "es5",
    "lib": ["es6", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDir": ".",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "allowSyntheticDefaultImports": true,
  },
  "exclude": [
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest",
    "src/setupTests.ts"
  ],
  "include": [
      "./src/**/*"
  ]
}

我现在需要在tsconfig.json中添加一些新内容吗?该项目编译并运行良好,但是此错误使我感到困扰

error

以下是npm软件包的版本:

{
  "name": "documentloader",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^3.0.3",
    "@material-ui/icons": "^3.0.1",
    "react": "16.5.2",
    "react-dom": "16.5.2",
    "react-redux": "^5.0.7",
    "react-redux-loading-bar": "^4.0.8",
    "react-router-dom": "^4.3.1",
    "react-scripts-ts": "latest",
    "react-toastify": "^4.4.0",
    "react-transition-group": "^2.5.0",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-persist": "^5.10.0",
    "redux-saga": "^0.16.2",
    "redux-thunk": "^2.3.0",
    "ts-loader": "^5.2.2"
  },
  "devDependencies": {
    "@types/classnames": "^2.2.6",
    "@types/history": "^4.7.1",
    "@types/jest": "^23.3.5",
    "@types/node": "10.12.0",
    "@types/ramda": "^0.25.39",
    "@types/react": "16.4.18",
    "@types/react-dom": "^16.0.9",
    "@types/react-redux": "^6.0.9",
    "@types/react-router-dom": "^4.3.1",
    "@types/redux-logger": "^3.0.6",
    "@types/webpack-env": "^1.13.6",
    "awesome-typescript-loader": "^5.2.1",
    "css-loader": "^1.0.0",
    "csstype": "^2.5.7",
    "file-loader": "^2.0.0",
    "html-webpack-plugin": "^3.2.0",
    "redux-devtools-extension": "^2.13.5",
    "source-map-loader": "^0.2.4",
    "style-loader": "^0.23.1",
    "typescript": "^3.1.3",
    "webpack": "^4.20.2",
    "webpack-cli": "^3.1.2",
    "webpack-dev-middleware": "^3.4.0",
    "webpack-dev-server": "^3.1.9",
    "webpack-hot-middleware": "^2.24.3"
  }
 }

更新

@ types / redux-logger文件夹的内容: folder

1 个答案:

答案 0 :(得分:0)

此错误很可能意味着typeRoots mechanism找到了一个目录,该目录似乎代表名为@types/redux-logger的程序包,但该目录不包含声明文件。如果node_modules/@types/redux-logger中的目录为空,请尝试将其删除。