【问题标题】:How to fix types duplicates?如何修复类型重复?
【发布时间】:2017-10-12 09:22:47
【问题描述】:

我想构建 typescript,它会抛出 Duplicate identifier

有什么问题,我想访问 WebRTC 类型。在我的 compilerOptions tsconfig.hson 我有

"lib": ["es2015", "es2016", "es2017", "dom.iterable", "dom", "scripthost"],

我需要dom。如果我将"@types/webrtc": "0.0.21", 添加到依赖项中,那么大多数部分都会显示Duplicate identifier

如果我不这样做,那么 RTCDataChannel 数据是未定义的,并且抛出重复的部分是可以的。

我需要RTCDataChannel 我怎样才能添加它而不会出现重复错误。 ?

tsconfig.json

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "rootDir": "src",
    "outDir": ".code",
    "newLine": "LF",
    "lib": ["es2015", "es2016", "es2017", "dom.iterable", "dom", "scripthost"],
    "moduleResolution": "node",
    "importHelpers": true,
    "declaration": true,
    "pretty": true,
    "sourceMap": true,
    "inlineSources": true,
    "noUnusedLocals": true
  },
  "exclude": [
    "node_modules",
    "dist",
    "es",
    "lib"
  ]
}

【问题讨论】:

    标签: typescript webrtc


    【解决方案1】:

    我在 tsconfig.json "skipLibCheck": true 中使用设置 compilerOptions 修复了它。

    它的作用是

    跳过所有声明文件 (*.d.ts) 的类型检查。

    【讨论】:

      猜你喜欢
      • 2016-11-12
      • 1970-01-01
      • 2019-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-28
      • 2019-10-23
      • 2018-07-27
      相关资源
      最近更新 更多