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

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"
    }
  }
}

当前回答

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

阅读更多

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

其他回答

我有这个问题,原来我在我的项目中有一个不应该在那里的第二个node_modules文件夹:-(

Angular的一个(可能的)解决方案

在我的例子中,当安装@angularfire。它会自动从我的环境文件中导入环境。这给出了重复标识符“环境”错误。

但是,我已经在同一个文件中导入了这个文件,因此导致了重复标识符错误。

我创建了一个新项目,一步一步地找到这个错误……

TL;DR:检查文件中的重复导入,出现错误。

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

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

我也遇到过类似的问题。简单地移动我的tsconfig。Json从我的项目的根到不同的范围有所帮助。在我的项目中,我移动了tsconfig。Json从根到wwwroot。

更新:typeings的1.0版本改变了输出结构,下面的答案涉及1.0之前的版本。

如果您正在使用tsconfig中的Typings和exclude。Json,你可能会遇到重复类型的问题,需要如下:

{
  "exclude": [
    "typings/browser.d.ts",
    "typings/browser",
    "node_modules"
  ]
}

为了简化与TypeScript的集成,有两个文件- types /main.d。t和类型/浏览器。d。生成t -引用项目中安装的所有类型,每次只能使用其中一个类型。

因此,根据您需要的版本,您应该排除(或包括)“浏览器”或“主”类型的文件,但不能同时排除(或包括)“浏览器”或“主”类型的文件,因为这是副本的来源。

这一期Typings将对此进行更多的讨论。