为什么我得到这个和更多类似的错误?我正在添加一个链接到回购以及下面的关键代码片段。我认为我对依赖和“包括”链接的工作方式有一个基本的误解。

csvproc(master)> tsc
node_modules/typescript/bin/lib.core.d.ts(83,5): error TS2300: Duplicate identifier 'configurable'.
node_modules/typescript/bin/lib.core.d.ts(84,5): error TS2300: Duplicate identifier 'enumerable'.
node_modules/typescript/bin/lib.core.d.ts(85,5): error TS2300: Duplicate identifier 'value'.
node_modules/typescript/bin/lib.core.d.ts(86,5): error TS2300: Duplicate identifier 'writable'.

所有代码都可以在这里找到。

我的tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": false,
        "outDir": "built/",
        "sourceMap": true,
        "target": "es5"
    }
}

我的tsd.json:

{
  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "master",
  "path": "typings",
  "bundle": "typings/tsd.d.ts",
  "installed": {
    "node/node-0.10.d.ts": {
      "commit": "6387999eb899d0ba02d37dd8697647718caca230"
    },
    "should/should.d.ts": {
      "commit": "e1182d56ccb192379eade6055d9ba3fb6a0bacc4"
    }
  }
}

我的tsd.d.ts:

{
  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "master",
  "path": "typings",
  "bundle": "typings/tsd.d.ts",
  "installed": {
    "node/node-0.10.d.ts": {
      "commit": "6387999eb899d0ba02d37dd8697647718caca230"
    },
    "should/should.d.ts": {
      "commit": "e1182d56ccb192379eade6055d9ba3fb6a0bacc4"
    }
  }
}

当前回答

我们从网站文件夹中删除了一个lib文件夹。这是由以前的类型安装创建的。这变成了重复。当这个被移除时,它工作了!

其他回答

完全关闭解决方案并重新运行项目解决了我的问题。

您还可以在tsconfig中使用exclude选项。Json文件如下:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "declaration": false,
    "noImplicitAny": false,
    "removeComments": true,
    "noLib": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  },
  "exclude": [
    "node_modules"
  ]
}

在我的例子中,我得到的错误是

node_modules/@types/es6-promise/index.d.ts(11,15):错误TS2300:重复标识符“承诺”。

我的包上有@types/es6-promise。Json,但我的tsconfig已经与目标:“es6”。所以我猜在编译时与Promise有冲突。

从包中删除@types/es6-promise。Json文件解决了这个问题。

从包中删除@types/express-validator。Json文件,然后运行NPM install

阅读更多

作者信息: 此包已弃用 这是express-validator的存根类型定义(https://github.com/ctavan/express-validator)。Express-validator提供了它自己的类型定义,所以你不需要安装@types/ Express-validator !

这可能是因为节点文件夹中同时存在类型和依赖项。 因此,首先检查你的@types文件夹中有什么,如果你有依赖项,删除重复项。 对我来说是core.js