javascript - typescript 错误 : Duplicate identifier 'LibraryManagedAttributes'

标签 javascript reactjs typescript

Failed to compile.

/moonholdings.io/node_modules/@types/react-dom/node_modules/@types/react/index.d.ts (2312,14): Duplicate identifier 'LibraryManagedAttributes'.

不知道为什么我会收到这个。

我已将我的 "@types/node" 从 10 降级到 8,但没有用。 还尝试了 "@types/node": "^9.6.7"

我的 repo :https://github.com/Futuratum/moonholdings.io

我的包.json

{
  "name": "moonholdings.io",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "build-css": "node-sass-chokidar src/ -o src/ --source-map",
    "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive --source-map",
    "start": "react-scripts-ts start",
    "build": "react-scripts-ts build",
    "test": "react-scripts-ts test --env=jsdom",
    "eject": "react-scripts-ts eject"
  },
  "dependencies": {
    "@types/react": "^16.4.14",
    "@types/react-redux": "^6.0.9",
    "node-sass-chokidar": "^1.3.3",
    "react": "^16.5.0",
    "react-dom": "^16.5.0",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.3.1",
    "react-scripts-ts": "2.17.0",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@types/jest": "^23.3.2",
    "@types/node": "^8.10.29",
    "@types/react-dom": "^16.0.7",
    "typescript": "^3.0.3"
  }
}

这是我的tsconfig

    {
  "compilerOptions": {
    "traceResolution": false,
    "strictNullChecks": true,
    "noImplicitAny": true,
    "module": "esnext",
    "target": "es5",
    "lib": [
      "es2015",
      "es2017",
      "es6",
      "es7",
      "es5",
      "dom"
    ],
    "jsx": "react",
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "baseUrl": "./src",
    "noUnusedLocals": true,
    "noUnusedParameters": false,
    "noImplicitAny": false,
    "allowSyntheticDefaultImports": true,
    "importHelpers": true,
    "strictFunctionTypes": false
  },
  "include": [
    "src/**/*",
    "webpack/**/*"
  ],
  "files": [
    "core.ts",
    "sys.ts",
    "types.ts",
    "tsc.ts",
    "registerServiceWorker.ts",
    "src/registerServiceWorker.ts",
    "src/setupTests.ts"
  ],
  "exclude": [
    "typings/browser.d.ts",
    "typings/browser",
    "typings",
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest"
  ]
}

最佳答案

您可能会发现重复项位于 node_modules/@types/reactnode_modules/types/react-dom/@types/react 或类似的集合中-向上,其中一个包对另一个包具有嵌套依赖性。

卸载并重新安装@types/react-dom 和@types/react 一起为我解决了问题。

yarn remove @types/react-dom @types/react


yarn add -D @types/react-dom @types/react

关于javascript - typescript 错误 : Duplicate identifier 'LibraryManagedAttributes' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52323056/

相关文章:

javascript - 如何使用 DOM 获取跨度之间的值

javascript - 如何使用 Javascript 和 HTML 从搜索栏中获取输入并同时处理搜索列表?

javascript - 如何从 javascript 提交带有本地列表的表单

javascript - 为什么有些跨域 JSON 请求会失败,而有些则不会?

javascript - 不支持 react 分析

angular - 如何找出组件或服务依赖于哪些模块?

javascript - 你如何加载 2 个 javascript 文件,它们之间可能有公共(public)变量并在 HTML 页面上访问它?

reactjs - 为什么我会遇到 : "TypeError: t(...).isPlaceholder is not a function" when "import ' ./bootstrap/dist/css/bootstrap.min.css'"

reactjs - React-Table:仅选择单行,禁用多行选择

typescript 2 : Array<any> and Array<Object> difference