我在一个ReactXP项目中工作,我必须使用ReactNative 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"
    }

还有Tconfig.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中添加"skipLibCheck": true.json

参考:https://github.com/DefinitelyTyped/DefinitelyTyped/issues/16825

React-native相关问答推荐

在我的 React Native 应用程序中获取数据返回 [object Object] 而不是 renderSectionHeader

导出命名空间应首先由 `@babel/plugin-proposal-export-namespace-from` 转换

useState 函数似乎阻止了 Animated.timing 事件?

Error: Invariant Violation: Touchable child must either be native or forward setNativeProps to a native component stack

如何在 react-native 中设置 Onpress On Textinput

设置 rootView.appProperties 不会重新渲染根组件

无法访问函数内部的状态

如何在 React Native 中访问原生 UI 组件的实例方法

ld:找不到-lFirebaseCore clang的库: error: linker command failed with exit code 1 (use -v to see invocation)

Property body[41] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression"

React-Native 应用程序中来自 Babel 的未知选项错误

在 react-native-maps 中渲染多个标记

在 react-native 中设置动态 'initialRouteName'

将 React Native 升级到 0.60-RC2 后找不到库libjsc.so

无法解析模块react-navigation

使用 React Navigation 导航堆栈时重新渲染组件

React Native如何将this.setState更改传递给父级

React Native,AppStore 请求 NSLocationAlwaysUsageDescription 值

如何在 React Native 中将图像放置在其他图像之上?

如何将 jest 测试移动到 /test 文件夹并让它们运行?