typescript - 错误 TS2300 : Duplicate identifier 'RequestInfo'

标签 typescript react-native reactxp

我在一个必须使用 React Native 的 ReactXP 项目中工作 native modules .

所以我将 react-native 类型作为开发依赖项包含在内。

我的项目现在无法编译,出现以下错误:

node_modules/@types/react-native/globals.d.ts(92,14): error TS2300: Duplicate identifier 'RequestInfo'.
node_modules/@types/react-native/index.d.ts(8751,11): error TS2451: Cannot redeclare block-scoped variable 'console'.
node_modules/@types/react-native/index.d.ts(8759,18): error TS2717: Subsequent property declarations must have the same type.  Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'.
node_modules/@types/react-native/index.d.ts(8762,11): error TS2451: Cannot redeclare block-scoped variable 'navigator'.
node_modules/typescript/lib/lib.dom.d.ts(15764,13): error TS2451: Cannot redeclare block-scoped variable'navigator'.
node_modules/typescript/lib/lib.dom.d.ts(15940,13): error TS2451: Cannot redeclare block-scoped variable'console'.
node_modules/typescript/lib/lib.dom.d.ts(15997,6): error TS2300: Duplicate identifier 'RequestInfo'.
18:17:44 - Compilation complete. Watching for file changes.

以下是我的 package.json 文件:

"dependencies": {
        "react": "^16.4.0",
        "react-dom": "^16.3.1",
        "react-native": "^0.55.4",
        "react-native-windows": "^0.54.0",
        "reactxp": "^1.2.1"
    },
    "devDependencies": {
        "@types/react-native": "^0.55.16",
        "@types/webpack": "^4.1.3",
        "@types/node": "9.6.7",
        "@types/react-dom": "^16.0.5",
        "awesome-typescript-loader": "^5.0.0",
        "rnpm-plugin-windows": "^0.2.8",
        "source-map-loader": "^0.2.3",
        "ts-node": "^5.0.1",
        "tslint": "^5.9.1",
        "tslint-microsoft-contrib": "^5.0.3",
        "typescript": "^2.8.1",
        "webpack": "^4.5.0",
        "webpack-cli": "^2.0.13"
    }

和 tsconfig.json 文件

{
  "exclude": [
    "node_modules"
  ],
  "compilerOptions": {
    "declaration": false,
    "noResolve": false,
    "jsx": "react",
    "reactNamespace": "RX",
    "module": "commonjs",
    "target": "es5",
    "experimentalDecorators": true,
    "sourceMap": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "outDir": "./dist/",
    "types": [
      "lodash",
      "react",
      "react-dom"
    ],
    "lib": [
      "es6",
      "dom"
    ],
  },
  "include": [
    "./src/ts/**/*"
  ]
}

我不明白我做错了什么。

感谢任何帮助。

最佳答案

在tsconfig.json中添加"skipLibCheck": true

引用:https://github.com/DefinitelyTyped/DefinitelyTyped/issues/16825

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

相关文章:

angular - 我如何从 Primeng 获取选项卡菜单中的选定项目

javascript - 如何将一个 RXJ 流用于 2 件不同的事情

javascript - RX.Component 类比 React.Component 提供了哪些特性?

javascript - react native vs reactXP

javascript - Angular2/Typescript/ngRx - 类型错误 : Cannot assign to read only property of object

typescript - 映射 typescript 类型

react-native - TextInput 中每次按键后键盘都会关闭

javascript - 使用 NativeBase Toast 组件时,无法在 React Native 中读取 null 的属性 '_root'

ios - React-Native 大量内存使用和仅来自 flatlist iOS 的崩溃